Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguity errors reported from SemanticModel.GetDiagnostics() for calls to partial members on type with primary constructor #75002

Open
cston opened this issue Sep 5, 2024 · 0 comments

Comments

@cston
Copy link
Member

cston commented Sep 5, 2024

Version Used: 2ff1a47

Steps to Reproduce:

Run the following unit test.

[Fact]
public void PartialMembers()
{
    var source1 = """
        C c = null;
        c.M();
        _ = c.P;
        """;
    var source2 = """
        partial class C(int p)
        {
            public partial void M() { }
            public partial void M();
            public partial object P { get; }
            public partial object P { get => null; }
        }
        """;
    var comp = CreateCompilation([source1, source2]);
    var tree = comp.SyntaxTrees[0];
    var model = comp.GetSemanticModel(tree);
    model.GetDiagnostics().Verify(
        // (2,3): error CS0121: The call is ambiguous between the following methods or properties: 'C.M()' and 'C.M()'
        // c.M();
        Diagnostic(ErrorCode.ERR_AmbigCall, "M").WithArguments("C.M()", "C.M()").WithLocation(2, 3),
        // (3,7): error CS0229: Ambiguity between 'C.P' and 'C.P'
        // _ = c.P;
        Diagnostic(ErrorCode.ERR_AmbigMember, "P").WithArguments("C.P", "C.P").WithLocation(3, 7));
}

Expected Behavior:
No errors from the call to model.GetDiagnostics().

Actual Behavior:
Ambiguity errors included above.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 5, 2024
cston added a commit to cston/roslyn that referenced this issue Sep 5, 2024
@jaredpar jaredpar added New Feature - Primary Constructors Bug and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 5, 2024
@jaredpar jaredpar added this to the Backlog milestone Sep 5, 2024
cston added a commit to cston/roslyn that referenced this issue Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants