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

EnC: Emit trampoline for deleted property that shadows primary parameter #69317

Open
tmat opened this issue Aug 1, 2023 · 0 comments
Open

EnC: Emit trampoline for deleted property that shadows primary parameter #69317

tmat opened this issue Aug 1, 2023 · 0 comments

Comments

@tmat
Copy link
Member

tmat commented Aug 1, 2023

When a property shadows primary constructor parameter and the property is renamed/deleted, the calls to this property from within the instance members of the type will currently throw MethodMissingException.

We could update all the methods to access the primary constructor, or do so from the deleted property.

Test in TopLevelEditingTests.cs

        [Fact]
        public void Property_Rename_ShadowingPrimaryParameter()
        {
            var src1 = @"
class C(int A, int B)
{
    public int B { get; init; } = B;

    public int F() => B;
}
";
            var src2 = @"
class C(int A, int B)
{
    public int D { get; init; } = B;

    public int F() => B;
}
";
            var edits = GetTopEdits(src1, src2);

            edits.VerifySemantics(
                new[]
                {
                    SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.get_B"), deletedSymbolContainerProvider: c => c.GetMember("C")),
                    SemanticEdit(SemanticEditKind.Delete, c => c.GetMember("C.set_B"), deletedSymbolContainerProvider: c => c.GetMember("C")),
                    SemanticEdit(SemanticEditKind.Insert, c => c.GetMember("C.D")),
                },
                capabilities: EditAndContinueCapabilities.AddMethodToExistingType | EditAndContinueCapabilities.AddInstanceFieldToExistingType);
        }
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Interactive untriaged Issues and PRs which have not yet been triaged by a lead labels Aug 1, 2023
@arunchndr arunchndr removed the untriaged Issues and PRs which have not yet been triaged by a lead label Aug 2, 2023
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