Repository navigation
ILC: Preserve declaring contexts for constrained NativeAOT calls - #137909
Merged
MichalStrehovsky merged 2 commits intoNov 20, 2026
Merged
Conversation
Reconstruct shared targets on their runtime-determined declaring interface or base type before applying method arguments. Share this reconstruction between the scanner, call lookup, and delegate construction, retaining constrained dispatch when the declaring context is ambiguous. Cover nested and swapped arguments, inherited contexts, and generic methods through calls and delegates. Fixes dotnet#137846.
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The regression can bypass scanner reconstruction and does not cover distinct declaring interfaces that canonicalize to the same owner, leaving reconstruction correctness and the ambiguity guard unverified.
What changed in this PR
This PR updates NativeAOT constrained-call resolution to preserve the implementation’s declaring interface or base-type context before applying method arguments.
Changes:
- Adds shared target reconstruction with fallback to constrained dispatch when the declaring context is ambiguous.
- Uses the reconstruction helper in scanning, call lookup, and delegate construction.
- Adds regression scenarios for nested, swapped, inherited, and generic contexts through calls and delegates.
| File | Description |
|---|---|
src/tests/Loader/classloader/StaticVirtualMethods/Regression/ConstrainedStaticInterfaceContext.csproj |
Configures the regression test with process isolation and tiering disabled. |
src/tests/Loader/classloader/StaticVirtualMethods/Regression/ConstrainedStaticInterfaceContext.cs |
Adds constrained-call and delegate regression scenarios. |
src/coreclr/tools/Common/Compiler/TypeExtensions.cs |
Adds declaring-context reconstruction and ambiguity detection. |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs |
Applies shared reconstruction to call and delegate lookup. |
src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs |
Aligns scanner dependencies with reconstructed targets. |
Review effort: Balanced
NinoFloris
force-pushed
the
jit/naot-constrained-substitution
branch
from
November 20, 2026 10:22
f1ae488 to
0efecea
Compare
Member
|
/ba-g abandoned macos legs |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Reconstruct shared targets on their runtime-determined declaring interface or base type before applying method arguments. Share this reconstruction between the scanner, call lookup, and delegate construction, retaining constrained dispatch when the declaring context is ambiguous.
Cover nested and swapped arguments, inherited contexts, and generic methods through calls and delegates. Fixes #137846.