You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There's also similar issue in assignment and possibly in invocations. See tests that refer to this issue.
[Fact,WorkItem("https://github.com/dotnet/roslyn/issues/75833")]publicvoidGetSymbolInfo_ImplicitUserDefinedConversionOnMethodGroup_InLocalDeclaration(){varsrc="""public class C{ public static void M() { C x = C.Test; } public static int Test() => 1; public static implicit operator C(System.Func<int> intDelegate) { return new C(); }}""";varcomp=CreateCompilation(src);comp.VerifyEmitDiagnostics(// (5,17): error CS0428: Cannot convert method group 'Test' to non-delegate type 'C'. Did you intend to invoke the method?// C x = C.Test;Diagnostic(ErrorCode.ERR_MethGrpToNonDel,"Test").WithArguments("Test","C").WithLocation(5,17));vartree=comp.SyntaxTrees.Single();varmodel=comp.GetSemanticModel(tree);varmemberAccess=GetSyntax<MemberAccessExpressionSyntax>(tree,"C.Test");Assert.Equal("C C.op_Implicit(System.Func<System.Int32> intDelegate)",model.GetSymbolInfo(memberAccess).Symbol.ToTestDisplayString());// Unexpected: Should be nullvarconversion=model.GetConversion(memberAccess);Assert.Equal(ConversionKind.ExplicitUserDefined,conversion.Kind);// Unexpected: Should be NoConversion or possibly Identity for error caseAssert.Equal(ConversionKind.MethodGroup,conversion.UserDefinedFromConversion.Kind);Assert.Equal(ConversionKind.Identity,conversion.UserDefinedToConversion.Kind);}[Fact,WorkItem("https://github.com/dotnet/roslyn/issues/75833")]publicvoidGetSymbolInfo_ImplicitUserDefinedConversionOnMethodGroup_WithToConversion_InLocalDeclaration(){varsrc="""public struct C{ public static void M() { C? x = C.Test; } public static int Test() => 1; public static implicit operator C(System.Func<int> intDelegate) { return new C(); }}""";varcomp=CreateCompilation(src);comp.VerifyEmitDiagnostics(// (5,18): error CS0428: Cannot convert method group 'Test' to non-delegate type 'C?'. Did you intend to invoke the method?// C? x = C.Test;Diagnostic(ErrorCode.ERR_MethGrpToNonDel,"Test").WithArguments("Test","C?").WithLocation(5,18));vartree=comp.SyntaxTrees.Single();varmodel=comp.GetSemanticModel(tree);varmemberAccess=GetSyntax<MemberAccessExpressionSyntax>(tree,"C.Test");Assert.Null(model.GetSymbolInfo(memberAccess).Symbol);varconversion=model.GetConversion(memberAccess);Assert.Equal(ConversionKind.ExplicitUserDefined,conversion.Kind);// Unexpected: Should be NoConversion or possibly Identity for error caseAssert.Equal(ConversionKind.MethodGroup,conversion.UserDefinedFromConversion.Kind);Assert.Equal(ConversionKind.Identity,conversion.UserDefinedToConversion.Kind);}
The text was updated successfully, but these errors were encountered:
This is less impactful than the scenario that was fixed because this is an error scenario. Also, this scenario doesn't go through the codepath that was affected in that fix/PR, so it was better to separate.
There's also similar issue in assignment and possibly in invocations. See tests that refer to this issue.
The text was updated successfully, but these errors were encountered: