Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/11.0.100.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Fix signature generation: backtick escaping for identifiers containing backticks. ([Issue #15389](https://github.com/dotnet/fsharp/issues/15389), [PR #19586](https://github.com/dotnet/fsharp/pull/19586))
* Fix signature generation: `private` keyword placement for prefix-style type abbreviations. ([Issue #15560](https://github.com/dotnet/fsharp/issues/15560), [PR #19586](https://github.com/dotnet/fsharp/pull/19586))
* Fix signature generation: missing `[<Class>]` attribute for types without visible constructors. ([Issue #16531](https://github.com/dotnet/fsharp/issues/16531), [PR #19586](https://github.com/dotnet/fsharp/pull/19586))
* Fix internal compiler error in `use` bindings when a C#-style `Dispose` extension method is in scope alongside `IDisposable.Dispose`. ([Issue #19552](https://github.com/dotnet/fsharp/issues/19552), [PR #19568](https://github.com/dotnet/fsharp/pull/19568))

### Added

Expand Down
2 changes: 1 addition & 1 deletion src/Compiler/Checking/Expressions/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3154,7 +3154,7 @@ let BuildDisposableCleanup (cenv: cenv) env m (v: Val) =
v.SetHasBeenReferenced()

let disposeMethod =
match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AllResults cenv env m ad "Dispose" g.system_IDisposable_ty with
match TryFindIntrinsicOrExtensionMethInfo ResultCollectionSettings.AtMostOneResult cenv env m ad "Dispose" g.system_IDisposable_ty with
| [x] -> x
| _ -> error(InternalError(FSComp.SR.tcCouldNotFindIDisposable(), m))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,29 @@ module UseBindings =
|> asFsx
|> compile
|> shouldSucceed

[<Fact>]
let ``use binding does not ICE when Dispose extension method is in scope`` () =
FSharp """
open System
open System.Runtime.CompilerServices

type Disposable() =
interface IDisposable with
member _.Dispose() = ()

[<Extension>]
type PublicExtensions =
[<Extension>]
static member inline Dispose(this: #IDisposable) =
this

let foo() =
use a = new Disposable()
()

foo()
"""
|> asExe
|> compile
|> shouldSucceed
Loading