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

Avoid synthesizing the parameterless struct constructor unnecessarily #72314

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

cston
Copy link
Member

@cston cston commented Feb 28, 2024

The parameterless struct constructor was synthesized unnecessarily if other instance constructors and a static constructor were declared before the parameterless constructor. The result was duplicate, ambiguous parameterless constructors.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 28, 2024
@cston cston requested a review from a team as a code owner February 28, 2024 19:38
"S..ctor(System.Int32 p)",
"S..ctor()");
VerifyExplicitlyDeclaredInstanceConstructors(
((Compilation)comp).GlobalNamespace.GetTypeMember("S"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference when obtaining the type symbol in this way, versus without the cast?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The symbols from Compilation are public API ISymbol, while the symbols from CSharpCompilation are internal Symbol. Since the ISymbol instances are generated from the Symbol instances, this additional test may not be that useful, but it seemed simple to include.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 1)

@RikkiGibson
Copy link
Contributor

nit: In future please link to the bug which the PR is solving the PR description (even if the bug is internal). Makes it a little easier to understand the goals/context of the PR.

@cston cston merged commit d765b8b into dotnet:main Feb 28, 2024
24 checks passed
@cston cston deleted the struct-ctor-ambiguity branch February 28, 2024 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants