Extensions: Ignore ref kind of extension parameter for static members in betterness#79885
Extensions: Ignore ref kind of extension parameter for static members in betterness#79885jcouv merged 2 commits intodotnet:mainfrom
Conversation
a133684 to
a80ef75
Compare
a80ef75 to
106a215
Compare
106a215 to
f4c85d3
Compare
| ParameterSymbol parameter = getParameterOrExtensionParameter(i, memberResolutionResult, parameters, member); | ||
|
|
||
| parameter1RefKind = parameter.RefKind; | ||
| parameterRefKind = GetParameterBetternessRefKind(parameter, member); |
There was a problem hiding this comment.
📝 I don't think this is observable. The callers of this local function who care about the returned parameterRefKind are for scenarios where the receiver is a COM import type, but a COM import type must be class or interface, which can't be used for extension parameter with ref modifier.
f4c85d3 to
97d3d09
Compare
97d3d09 to
81caf40
Compare
|
@dotnet/roslyn-compiler for second review. Thanks |
|
@dotnet/roslyn-compiler for second review. Thanks |
1 similar comment
|
@dotnet/roslyn-compiler for second review. Thanks |
| private static RefKind GetParameterBetternessRefKind<TMember>(ParameterSymbol parameter, TMember member) where TMember : Symbol | ||
| { | ||
| // For static extension members, the ref kind of the extension parameter shouldn't affect betterness. | ||
| bool isExtensionParameterOfStaticExtensionMember = parameter is { ContainingSymbol: TypeSymbol { IsExtension: true } } && member.IsStatic; |
There was a problem hiding this comment.
nit: it might also be good to check parameter == parameter.ContainingSymbol.ExtensionParameter. #Resolved
| comp.VerifyEmitDiagnostics( | ||
| // (1,22): error CS9286: 'int' does not contain a definition for 'P' and no accessible extension member 'P' for receiver of type 'int' could be found (are you missing a using directive or an assembly reference?) | ||
| // System.Console.Write(int.P); | ||
| Diagnostic(ErrorCode.ERR_ExtensionResolutionFailed, "int.P").WithArguments("int", "P").WithLocation(1, 22)); |
There was a problem hiding this comment.
Could you explain this result? I expected the diagnostic to mention that the lookup is ambiguous, but, instead the message indicates there is no member with the given name. It would be good to at least mark this as something we can improve in the future. #Resolved
There was a problem hiding this comment.
Added link to existing tracking issue for this
Closes #79171
Relates to test plan #76130