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

A follow up is needed for a process of merging backing fields for a partial property #76870

Open
AlekseyTs opened this issue Jan 22, 2025 · 1 comment
Labels
Area-Compilers Feature - Partial Properties untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@AlekseyTs
Copy link
Contributor

AlekseyTs commented Jan 22, 2025

It looks like initially PartialDefinitionPart and PartialImplementationPart are created with their own unique backing field symbols. After the parts are merged, ContainingType.GetMembers() contains PartialDefinitionPart.BackingField and PartialImplementationPart.BackingField is adjusted to point to that field symbolas well. The field symbol originally created for PartialImplementationPart is not among ContainingType.GetMembers(), but if the implementation part has an initializer, corresponding bound field initializer refers to that field, rather than to the PartialDefinitionPart.BackingField. Also, it is very likely that PartialDefinitionPart.BackingField.HasInitializer is set to false. Emitted code for a simple scenario looks correct, likely due to the fact that the fields share the same name. However, the internal compiler data structures look inconsistent, which potentially might cause observable problems in some scenarios.

Another aspect is the FieldSymbol.AssociatedSymbol's behavior. Is it supposed to return PartialDefinitionPart or PartialImplementationPart? Whatever the answer is, it feels inappropriate for the other part to return the same field symbol from BackingField.

@AlekseyTs
Copy link
Contributor Author

A workaround for the inconsistency is added to #76871, otherwise several tests in PartialPropertiesTests and FieldKeywordTests were asserting in AssertMemberExposure.

AlekseyTs added a commit that referenced this issue Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - Partial Properties untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

1 participant