Skip to content

Commit 86b7584

Browse files
authored
Respect generic arity in method uniqueness (#17804)
1 parent 0a5901f commit 86b7584

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
### Fixed
2+
3+
* Fix internal error when calling 'AddSingleton' and other overloads only differing in generic arity ([PR #17804](https://github.com/dotnet/fsharp/pull/17804))
24
* Fix extension methods support for non-reference system assemblies ([PR #17799](https://github.com/dotnet/fsharp/pull/17799))
35
* Ensure `frameworkTcImportsCache` mutations are threadsafe. ([PR #17795](https://github.com/dotnet/fsharp/pull/17795))
46

7+
58
### Added
69

710

src/Compiler/AbstractIL/il.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5700,6 +5700,7 @@ let resolveILMethodRefWithRescope r (td: ILTypeDef) (mref: ILMethodRef) =
57005700
mref.CallingConv = md.CallingConv
57015701
&& (md.Parameters, argTypes)
57025702
||> List.lengthsEqAndForall2 (fun p1 p2 -> r p1.Type = p2)
5703+
&& md.GenericParams.Length = mref.GenericArity
57035704
&&
57045705
// REVIEW: this uses equality on ILType. For CMOD_OPTIONAL this is not going to be correct
57055706
r md.Return.Type = retType)

tests/FSharp.Compiler.Private.Scripting.UnitTests/FSharpScriptTests.fs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,3 +502,17 @@ test pfloat "1.234"
502502
let opt = script.Eval(code) |> getValue
503503
let value = opt.Value
504504
Assert.True(true = downcast value.ReflectionValue)
505+
506+
[<Fact>]
507+
member _.``Nuget package with method duplicates differing only in generic arity``() =
508+
// regression test for: https://github.com/dotnet/fsharp/issues/17796
509+
// Was an internal error
510+
let code = """
511+
#r "nuget: Microsoft.Extensions.DependencyInjection.Abstractions"
512+
open Microsoft.Extensions.DependencyInjection
513+
let add (col:IServiceCollection) =
514+
col.AddSingleton<string,string>()
515+
"""
516+
use script = new FSharpScript(additionalArgs=[| |])
517+
let _value,diag = script.Eval(code)
518+
Assert.Empty(diag)

0 commit comments

Comments
 (0)