-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Avoid virtual implementations for AddSynthesizedAttributes
#81289
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
base: main
Are you sure you want to change the base?
Conversation
| foreach (var tp in oldTypeParameters) | ||
| { | ||
| var newTp = synthesized ? | ||
| TypeParameterSymbol newTp = synthesized ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, the types no longer inherit from each other, a target type is necessary.
| namespace Microsoft.CodeAnalysis.CSharp.Symbols | ||
| { | ||
| internal class SubstitutedTypeParameterSymbol : WrappedTypeParameterSymbol | ||
| internal sealed class SubstitutedTypeParameterSymbol : SubstitutedTypeParameterSymbolBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// A type parameter for a synthesized class or method. | ||
| /// </summary> | ||
| internal sealed class SynthesizedSubstitutedTypeParameterSymbol : SubstitutedTypeParameterSymbol | ||
| internal sealed class SynthesizedSubstitutedTypeParameterSymbol : SubstitutedTypeParameterSymbolBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should change name of this type. I think it always represents a definition of a synthesized type parameter and "Substituted" in the name adds some confusion. I suggest removing it and use "SynthesizedTypeParameterSymbol" as the name for the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then adding synthesized attributes would totally make sense for this symbol.
I suggest asserting the following condition in this constructor: Refers to: src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSubstitutedTypeParameterSymbol.cs:27 in 4b84820. [](commit_id = 4b84820, deletion_comment = False) |
| { | ||
| internal SubstitutedTypeParameterSymbol(Symbol newContainer, TypeMap map, TypeParameterSymbol substitutedFrom, int ordinal) | ||
| : base(newContainer, map, substitutedFrom, ordinal) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are splitting types, I suggest to keep going and splitting implementation of this method as well by doing the following:
Refers to: src/Compilers/CSharp/Portable/Symbols/SubstitutedTypeParameterSymbol.cs:62 in 4b84820. [](commit_id = 4b84820, deletion_comment = False) |
| } | ||
| } | ||
|
|
||
| internal sealed override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<CSharpAttributeData> attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<CSharpAttributeData> attributes) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| protected class RewrittenMethodParameterSymbol : RewrittenParameterSymbol | ||
| protected class RewrittenMethodParameterSymbol : RewrittenMethodParameterSymbolBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| internal sealed override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, ref ArrayBuilder<CSharpAttributeData> attributes) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| protected class RewrittenMethodParameterSymbol : RewrittenParameterSymbol | ||
| protected class RewrittenMethodParameterSymbol : RewrittenMethodParameterSymbolBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Done with review pass (commit 4) |
Closes #78655