File tree Expand file tree Collapse file tree 2 files changed +68
-1
lines changed
tests/FSharp.Compiler.ComponentTests/Signatures Expand file tree Collapse file tree 2 files changed +68
-1
lines changed Original file line number Diff line number Diff line change @@ -3948,7 +3948,17 @@ module TcDeclarations =
39483948 let resInfo = TypeNameResolutionStaticArgsInfo.FromTyArgs synTypars.Length
39493949 let _ , tcref =
39503950 match ResolveTypeLongIdent cenv.tcSink cenv.nameResolver ItemOccurence.Binding OpenQualified envForDecls.NameEnv ad longPath resInfo PermitDirectReferenceToGeneratedType.No with
3951- | Result res -> res
3951+ | Result res ->
3952+ // Update resolved type parameters with the names from the source.
3953+ let _ , tcref = res
3954+ if tcref.TyparsNoRange.Length = synTypars.Length then
3955+ ( tcref.TyparsNoRange, synTypars)
3956+ ||> List.zip
3957+ |> List.iter ( fun ( typar , SynTyparDecl.SynTyparDecl ( _ , SynTypar ( ident = untypedIdent ))) ->
3958+ typar.SetIdent( untypedIdent)
3959+ )
3960+
3961+ res
39523962 | res when inSig && List.isSingleton longPath ->
39533963 errorR( Deprecated( FSComp.SR.tcReservedSyntaxForAugmentation(), m))
39543964 ForceRaise res
Original file line number Diff line number Diff line change @@ -75,3 +75,60 @@ namespace Foo.Types
7575 val EndLine: int
7676
7777 val EndColumn: int"""
78+
79+ [<Fact>]
80+ let ``Type extension uses type parameters names from source`` () =
81+ FSharp """
82+ module Extensions
83+
84+ type List<'E> with
85+
86+ member this.X = this.Head
87+ """
88+ |> printSignatures
89+ |> should equal
90+ """
91+ module Extensions
92+ type List<'E> with
93+
94+ member X: 'E"""
95+
96+ [<Fact>]
97+ let ``Type extension with constraints uses type parameters names from source`` () =
98+ FSharp """
99+ module Extensions
100+
101+ type Map<'K, 'V when 'K: comparison> with
102+
103+ member m.X (t: 'T) (k: 'K) = Some k, ({| n = [|k|] |}, 0)
104+ """
105+ |> printSignatures
106+ |> should equal
107+ """
108+ module Extensions
109+ type Map<'K,'V when 'K: comparison> with
110+
111+ member X: t: 'T -> k: 'K -> 'K option * ({| n: 'K array |} * int) when 'K: comparison"""
112+
113+ [<Fact>]
114+ let ``Type extension with lowercase type parameters names from source`` () =
115+ FSharp """
116+ module Extensions
117+
118+ open System.Collections.Concurrent
119+
120+ type ConcurrentDictionary<'key, 'value> with
121+
122+ member x.TryFind key =
123+ match x.TryGetValue key with
124+ | true, value -> Some value
125+ | _ -> None
126+ """
127+ |> printSignatures
128+ |> should equal
129+ """
130+ module Extensions
131+ type System.Collections.Concurrent.ConcurrentDictionary<'key,'value> with
132+
133+ member TryFind: key: 'key -> 'value option"""
134+
You can’t perform that action at this time.
0 commit comments