@@ -115,7 +115,7 @@ internal bool TryMostSpecific(ISymbol? x, ISymbol? y, Compilation compilation, [
115115 return false ;
116116 }
117117
118- return this . TryMostSpecific ( x as IMethodSymbol , y as IMethodSymbol , compilation , out unique ) ;
118+ return this . TryMostSpecific ( Parameters ( x ) , Parameters ( y ) , compilation , out unique ) ;
119119
120120 static bool ByNull ( ISymbol ? first , ISymbol ? other , [ NotNullWhen ( true ) ] out ISymbol ? result )
121121 {
@@ -129,6 +129,16 @@ static bool ByNull(ISymbol? first, ISymbol? other, [NotNullWhen(true)] out ISymb
129129 result = null ;
130130 return false ;
131131 }
132+
133+ static ImmutableArray < IParameterSymbol > Parameters ( ISymbol symbol )
134+ {
135+ return symbol switch
136+ {
137+ IMethodSymbol method => method . Parameters ,
138+ IPropertySymbol property => property . Parameters ,
139+ _ => ImmutableArray < IParameterSymbol > . Empty ,
140+ } ;
141+ }
132142 }
133143
134144 private static bool TryGetTypesArgument ( InvocationExpressionSyntax invocation , IMethodSymbol getX , [ NotNullWhen ( true ) ] out ArgumentSyntax ? argument )
@@ -138,11 +148,11 @@ private static bool TryGetTypesArgument(InvocationExpressionSyntax invocation, I
138148 invocation . TryFindArgument ( parameter , out argument ) ;
139149 }
140150
141- private bool TryMostSpecific ( IMethodSymbol ? x , IMethodSymbol ? y , Compilation compilation , [ NotNullWhen ( true ) ] out ISymbol ? unique )
151+ private bool TryMostSpecific ( ImmutableArray < IParameterSymbol > x , ImmutableArray < IParameterSymbol > y , Compilation compilation , [ NotNullWhen ( true ) ] out ISymbol ? unique )
142152 {
143153 if ( this . Argument is null ||
144- x is null ||
145- y is null )
154+ x . IsDefaultOrEmpty ||
155+ y . IsDefaultOrEmpty )
146156 {
147157 unique = null ;
148158 return false ;
@@ -154,8 +164,8 @@ x is null ||
154164 return true ;
155165 }
156166
157- if ( this . Matches ( x . Parameters , compilation ) &&
158- this . Matches ( y . Parameters , compilation ) )
167+ if ( this . Matches ( x , compilation ) &&
168+ this . Matches ( y , compilation ) )
159169 {
160170 var sum = 0 ;
161171 for ( var i = 0 ; i < this . Symbols . Length ; i ++ )
@@ -169,50 +179,50 @@ x is null ||
169179 return false ;
170180 }
171181
172- unique = sum < 0 ? x : y ;
182+ unique = sum < 0 ? x [ 0 ] . ContainingSymbol : y [ 0 ] . ContainingSymbol ;
173183 return true ;
174184 }
175185
176- if ( this . Matches ( x . Parameters , compilation ) )
186+ if ( this . Matches ( x , compilation ) )
177187 {
178- unique = x ;
188+ unique = x [ 0 ] . ContainingSymbol ;
179189 return true ;
180190 }
181191
182- if ( this . Matches ( y . Parameters , compilation ) )
192+ if ( this . Matches ( y , compilation ) )
183193 {
184- unique = y ;
194+ unique = y [ 0 ] . ContainingSymbol ;
185195 return true ;
186196 }
187197
188198 unique = null ;
189199 return false ;
190200
191- static bool TryExact ( ImmutableArray < ITypeSymbol > symbols , IMethodSymbol method , [ NotNullWhen ( true ) ] out ISymbol ? result )
201+ static bool TryExact ( ImmutableArray < ITypeSymbol > symbols , ImmutableArray < IParameterSymbol > parameters , [ NotNullWhen ( true ) ] out ISymbol ? result )
192202 {
193- if ( method . Parameters . Length != symbols . Length )
203+ if ( parameters . Length != symbols . Length )
194204 {
195205 result = null ;
196206 return false ;
197207 }
198208
199- for ( var i = 0 ; i < method . Parameters . Length ; i ++ )
209+ for ( var i = 0 ; i < parameters . Length ; i ++ )
200210 {
201- if ( ! TypeSymbolComparer . Equal ( symbols [ i ] , method . Parameters [ i ] . Type ) )
211+ if ( ! TypeSymbolComparer . Equal ( symbols [ i ] , parameters [ i ] . Type ) )
202212 {
203213 result = null ;
204214 return false ;
205215 }
206216 }
207217
208- result = method ;
218+ result = parameters [ 0 ] . ContainingSymbol ;
209219 return true ;
210220 }
211221
212222 int ByIndex ( int index , ImmutableArray < ITypeSymbol > symbols )
213223 {
214- var xt = x ! . Parameters [ index ] . Type ;
215- var yt = y ! . Parameters [ index ] . Type ;
224+ var xt = x [ index ] . Type ;
225+ var yt = y [ index ] . Type ;
216226 if ( TypeSymbolComparer . Equal ( xt , yt ) )
217227 {
218228 return 0 ;
0 commit comments