-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Flesh out handling of symbols synthesized during lowering of extension methods #77287
base: features/extensions
Are you sure you want to change the base?
Conversation
@@ -1039,6 +1039,8 @@ internal override void AddSynthesizedAttributes(PEModuleBuilder moduleBuilder, r | |||
// The async state machine type is not synthesized until the async method body is rewritten. If we are | |||
// only emitting metadata the method body will not have been rewritten, and the async state machine | |||
// type will not have been created. In this case, omit the attribute. | |||
|
|||
// PROTOTYPE: These attributes probably should be synthesized only on the extension implementation method | |||
if (moduleBuilder.CompilationState.TryGetStateMachineType(MethodCompiler.TryGetCorrespondingExtensionImplementationMethod(this) ?? (MethodSymbol)this, out NamedTypeSymbol stateMachineType)) |
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.
Looks like TryGetCorrespondingExtensionImplementationMethod
is no longer used inside MethodCompiler
, so perhaps it shouldn't live there? #Resolved
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.
perhaps it shouldn't live there?
I like its current location and at this point we don't even know whether the method will survive at the end.
@@ -2090,5 +2090,29 @@ internal bool TryGetTranslatedImports(ImportChain chain, out ImmutableArray<Cci. | |||
{ | |||
return _translatedImportsMap.GetOrAdd(chain, imports); | |||
} | |||
|
|||
public override void AddSynthesizedDefinition(NamedTypeSymbol container, Cci.INestedTypeDefinition nestedType) |
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.
Consider marking as sealed override
here and below. #Resolved
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 no reason to seal these overrides.
internal DelegateCacheContainer(TypeSymbol containingType, int generationOrdinal) | ||
: base(GeneratedNames.DelegateCacheContainerType(generationOrdinal), containingMethod: null) | ||
internal DelegateCacheContainer(NamedTypeSymbol containingType, int generationOrdinal) | ||
: base(GeneratedNames.DelegateCacheContainerType(generationOrdinal), []) | ||
{ | ||
Debug.Assert(containingType.IsDefinition); | ||
|
||
_containingSymbol = containingType; | ||
} | ||
|
||
/// <summary>Creates a method-scope generic delegate cache container.</summary> |
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.
@@ -22,7 +22,7 @@ internal sealed class DelegateCacheRewriter | |||
private readonly SyntheticBoundNodeFactory _factory; | |||
private readonly int _topLevelMethodOrdinal; | |||
|
|||
private Dictionary<MethodSymbol, DelegateCacheContainer>? _genericCacheContainers; | |||
private Dictionary<Symbol, DelegateCacheContainer>? _genericCacheContainers; |
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.
Consider updating the doc comment of DelegateCacheRewriter
since it doesn't target just methods anymore. #Resolved
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.
Consider updating the doc comment of
DelegateCacheRewriter
since it doesn't target just methods anymore.
Could you, please, elaborate? I think the purpose of the rewriter and what it targets isn't changed in this PR.
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.
You are right, I have misinterpreted the doc comment.
|
||
_containingSymbol = ownerMethod.ContainingType; | ||
_containingSymbol = containingType; | ||
_constructedContainer = Construct(ConstructedFromTypeParameters); | ||
} | ||
|
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.
Is the PROTOTYPE comment below still necessary? #Resolved
@jcouv, @dotnet/roslyn-compiler For the second review |
1 similar comment
@jcouv, @dotnet/roslyn-compiler For the second review |
Relates to test plan #76130