Repository navigation
Track async variants when generating generic dictionaries - #121573
Merged
Merged
Conversation
In `GenericDictionaryNode` we have a piece of code that ensures whenever a canonical method body of a method on a type depends on something and we have a concrete instance of such type, the specialized thing is also created.
For example, `class Foo<T> { Type GrabType() => typeof(List<T>); }`: when we compile `Foo<__Canon>.GrabType` we find out we need `List<T>`. Elsewhere we find out we need `Foo<object>`. The code in GenericDictionaryNode that I'm modifying ensures we also generate `List<object>`.
We do this by walking all methods on the type and generating special `ShadowConcrete` dependencies for any canonical bodies of the methods on the type. We were missing async variants from this reporting.
Contributor
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors and extends the handling of async method variants in the AOT compiler's dependency analysis to ensure that async variants are properly tracked when generating generic dictionaries and type dependencies.
Key Changes:
- Introduces a new extension method
GetAllMethodsAndAsyncVariants()to make async variant enumeration reusable - Updates
GenericDictionaryNodeandEETypeNodeto include async variants in their dependency tracking - Refactors
WithAsyncVariantsfrom a nested loop into a standalone internal method for broader reusability
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| CompilerTypeSystemContext.Async.cs | Adds GetAllMethodsAndAsyncVariants() extension method and refactors WithAsyncVariants() into a reusable internal method with enhanced logic to handle both virtual and non-virtual async methods |
| GenericDictionaryNode.cs | Updates dependency tracking to use GetAllMethodsAndAsyncVariants() instead of GetAllMethods(), ensuring async method variants are included in generic dictionary dependencies |
| EETypeNode.cs | Updates multifile compilation dependency tracking to use GetAllMethodsAndAsyncVariants(), ensuring async variants are exported when types are shared across modules |
This was referenced Nov 13, 2025
Open
jkotas
approved these changes
Nov 13, 2025
Member
Author
|
/ba-g timeouts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
GenericDictionaryNodewe have a piece of code that ensures whenever a canonical method body of a method on a type depends on something and we have a concrete instance of such type, the specialized thing is also created.For example,
class Foo<T> { Type GrabType() => typeof(List<T>); }: when we compileFoo<__Canon>.GrabTypewe find out we needList<T>. Elsewhere we find out we needFoo<object>. The code in GenericDictionaryNode that I'm modifying ensures we also generateList<object>.We do this by walking all methods on the type and generating special
ShadowConcretedependencies for any canonical bodies of the methods on the type. We were missing async variants from this reporting.The change in EETypeNode is related, but only affects multifile compilation that we don't care much about. I'm fixing it because it has the same problem.
Cc @dotnet/ilc-contrib