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

[release/dev17.12] Respect generic arity in method uniqueness #17805

Merged
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
1 change: 1 addition & 0 deletions src/Compiler/AbstractIL/il.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5690,6 +5690,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 @@ -486,3 +486,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"
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)