diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 9ed1822676b..2aadea335e1 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -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) diff --git a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs index 50c354da629..a8739d93390 100644 --- a/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs +++ b/tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs @@ -486,3 +486,17 @@ test pfloat "1.234" let opt = script.Eval(code) |> getValue let value = opt.Value Assert.True(true = downcast value.ReflectionValue) + + [] + 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() +""" + use script = new FSharpScript(additionalArgs=[| |]) + let _value,diag = script.Eval(code) + Assert.Empty(diag)