Fix static interface dispatch issue in the managed type system#121167
Open
MichalStrehovsky wants to merge 3 commits intodotnet:mainfrom
Open
Fix static interface dispatch issue in the managed type system#121167MichalStrehovsky wants to merge 3 commits intodotnet:mainfrom
MichalStrehovsky wants to merge 3 commits intodotnet:mainfrom
Conversation
Open
3 tasks
Member
Author
|
/azp run runtime-nativeaot-outerloop |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was referenced Oct 30, 2025
Contributor
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Contributor
|
Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a static interface dispatch issue in the managed type system that was causing the compiler to hit "invalid IL" codepaths when resolving default implementations of static virtual interface methods.
Key Changes:
- Enhanced variant interface method resolution to properly consider the interface itself when looking for default implementations
- Added early resolution check to avoid redundant processing
- Updated assertion logic to account for non-abstract static virtual methods with default implementations
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/coreclr/tools/Common/TypeSystem/Common/MetadataVirtualMethodAlgorithm.cs | Modified ResolveVariantInterfaceMethodToDefaultImplementationOnType to first check for exact matches, then include the current interface type itself in the list of considered interfaces when resolving variant default implementations |
| src/coreclr/tools/Common/Compiler/TypeExtensions.cs | Updated Debug.Assert to allow for the case where a static virtual method has a default implementation (non-abstract), relaxing the assertion to prevent false failures |
| src/tests/Loader/classloader/StaticVirtualMethods/Regression/SimpleStaticVirtual.cs | Added regression test that exercises static virtual methods with default implementations on interfaces, including variant generic interface scenarios |
| src/tests/Loader/classloader/StaticVirtualMethods/Regression/SimpleStaticVirtual.csproj | Added test project file following the standard pattern for this test directory |
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.
Ran into this in an Android MAUI app. We don't hit this codepath at runtime, probably, but the compiler was hitting "invalid IL" codepaths and recovering from this.
Cc @dotnet/ilc-contrib