Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect generic arity in method uniqueness #17804

Merged
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
3 changes: 3 additions & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.200.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
### Fixed

* Fix internal error when calling 'AddSingleton' and other overloads only differing in generic arity ([PR #17804](https://github.com/dotnet/fsharp/pull/17804))
* Fix extension methods support for non-reference system assemblies ([PR #17799](https://github.com/dotnet/fsharp/pull/17799))
* Ensure `frameworkTcImportsCache` mutations are threadsafe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))


### Added


Expand Down
1 change: 1 addition & 0 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5700,6 +5700,7 @@ let resolveILMethodRefWithRescope r (td: ILTypeDef) (mref: ILMethodRef) =
mref.CallingConv = md.CallingConv
&& (md.Parameters, argTypes)
||> List.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2)
&& md.GenericParams.Length = mref.GenericArity
&&
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
r md.Return.Type = retType)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,17 @@ test pfloat "1.234"
let opt = script.Eval(code) |> getValue
let value = opt.Value
Assert.True(true = downcast value.ReflectionValue)

[<Fact>]
member _.``Nuget package with method duplicates differing only in generic arity``() =
// regression test for: https://github.com/dotnet/fsharp/issues/17796
// Was an internal error
let code = """
#r "nuget: Microsoft.Extensions.DependencyInjection.Abstractions"
T-Gro marked this conversation as resolved.
Show resolved Hide resolved
open Microsoft.Extensions.DependencyInjection
let add (col:IServiceCollection) =
col.AddSingleton<string,string>()
"""
use script = new FSharpScript(additionalArgs=[| |])
let _value,diag = script.Eval(code)
Assert.Empty(diag)
Loading