Fix dataflow analysis of lambdas in async methods#122623
Merged
MichalStrehovsky merged 2 commits intodotnet:mainfrom Dec 22, 2025
Merged
Fix dataflow analysis of lambdas in async methods#122623MichalStrehovsky merged 2 commits intodotnet:mainfrom
MichalStrehovsky merged 2 commits intodotnet:mainfrom
Conversation
To the same tune as dotnet#122450. This is a bug farm, as expected, but likely still better than trying to teach the code that is shared with ILLink and Roslyn analyzer about async variants.
Contributor
|
Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in dataflow analysis where lambdas and local functions within async methods were not being properly analyzed. The fix unwraps AsyncMethodVariant instances to their target methods before performing compiler-generated member analysis, following the same pattern used elsewhere in the codebase for handling async variants.
Key Changes
- Added logic to unwrap
AsyncMethodVariantto its target method in the dataflow analysis path - Added test coverage for async methods containing local async methods with dataflow warnings
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/CompilerGeneratedState.cs | Added AsyncMethodVariant unwrapping logic in TryGetUserMethodForCompilerGeneratedMember to properly resolve user methods for compiler-generated members in async contexts |
| src/tools/illink/test/Mono.Linker.Tests.Cases/DataFlow/RuntimeAsyncMethods.cs | Added test case RuntimeAsyncWithAwaitedLocalMethod to verify dataflow warnings are correctly emitted for local async methods, and added System.Reflection using directive |
3 tasks
jtschuster
approved these changes
Dec 18, 2025
This was referenced Jan 9, 2026
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.
To the same tune as #122450. This is a bug farm, as expected, but likely still better than trying to teach the code that is shared with ILLink and Roslyn analyzer about async variants.
Cc @dotnet/ilc-contrib