Skip to content

Commit 22dcea4

Browse files
Fix FAR with method type paarameters
1 parent cd134f7 commit 22dcea4

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/EditorFeatures/Test2/FindReferences/FindReferencesTests.MethodTypeParameterTypeSymbol.vb

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,61 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.FindReferences
129129
Await TestAPIAndFeature(input, kind, host)
130130
End Function
131131

132+
<WpfTheory, CombinatorialData>
133+
Public Async Function TestMethodTypeParameter_TopLevelLocalFunction(kind As TestKind, host As TestHost) As Task
134+
Dim input =
135+
<Workspace>
136+
<Project Language="C#" CommonReferences="true">
137+
<Document><![CDATA[
138+
[|T|] TopLevelLocalFunction<{|Definition:$$T|}>() where [|T|] : new()
139+
{
140+
return new [|T|]();
141+
}]]></Document>
142+
</Project>
143+
</Workspace>
144+
Await TestAPIAndFeature(input, kind, host)
145+
End Function
146+
147+
<WpfTheory, CombinatorialData>
148+
Public Async Function TestMethodTypeParameter_MethodLevelLocalFunction(kind As TestKind, host As TestHost) As Task
149+
Dim input =
150+
<Workspace>
151+
<Project Language="C#" CommonReferences="true">
152+
<Document><![CDATA[
153+
class C
154+
{
155+
void Goo()
156+
{
157+
[|T|] LocalFunction<{|Definition:$$T|}>() where [|T|] : new()
158+
{
159+
return new [|T|]();
160+
}
161+
}
162+
}]]></Document>
163+
</Project>
164+
</Workspace>
165+
Await TestAPIAndFeature(input, kind, host)
166+
End Function
167+
168+
<WpfTheory, CombinatorialData>
169+
Public Async Function TestMethodTypeParameter_NormalMethod(kind As TestKind, host As TestHost) As Task
170+
Dim input =
171+
<Workspace>
172+
<Project Language="C#" CommonReferences="true">
173+
<Document><![CDATA[
174+
class C
175+
{
176+
[|T|] TopLevelMethod<{|Definition:$$T|}>() where [|T|] : new()
177+
{
178+
return new [|T|]();
179+
}
180+
}
181+
}]]></Document>
182+
</Project>
183+
</Workspace>
184+
Await TestAPIAndFeature(input, kind, host)
185+
End Function
186+
132187
#End Region
133188

134189
#Region "FAR on generic partial methods"

src/Workspaces/Core/Portable/FindSymbols/FindReferences/Finders/AbstractTypeParameterSymbolReferenceFinder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Immutable;
77
using System.Threading;
88
using Microsoft.CodeAnalysis.LanguageService;
9+
using Microsoft.CodeAnalysis.Shared.Utilities;
910
using Roslyn.Utilities;
1011

1112
namespace Microsoft.CodeAnalysis.FindSymbols.Finders;
@@ -60,7 +61,7 @@ void GetObjectCreationReferences(
6061
{
6162
Contract.ThrowIfNull(token.Parent?.Parent);
6263
var typeInfo = state.SemanticModel.GetTypeInfo(token.Parent.Parent, cancellationToken);
63-
if (symbol.Equals(typeInfo.Type, SymbolEqualityComparer.Default))
64+
if (SymbolEquivalenceComparer.Instance.Equals(symbol, typeInfo.Type))
6465
processResult(CreateFinderLocation(state, token, CandidateReason.None, cancellationToken), processResultData);
6566
}
6667
}

0 commit comments

Comments
 (0)