Uh oh!
There was an error while loading. Please reload this page.
[release/10.0] Fix Crossgen2 variance validation for type constraints - #133118
[release/10.0] Fix Crossgen2 variance validation for type constraints#133118jtschuster wants to merge 1 commit into
Conversation
Crossgen2 applied method generic-constraint variance rules to a generic type's own constraints. ECMA-335 II.9.7 explicitly leaves type-owned constraints unrestricted, so valid variant interfaces could fail automatic validation and omit `READYTORUN_FLAG_SkipTypeValidation`. This change: - removes the invalid variance check for type-owned generic constraints - aligns interface method signature validation with the VM by checking all instance methods and virtual methods, including static virtual and static abstract declarations - adds a ReadyToRun regression test based on the reported constraint pattern Fixesdotnet#132724 > [!NOTE] > This pull request was created with GitHub Copilot. (cherry picked from commit 65c1f69)
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Tagging subscribers to this area: @dotnet/crossgen-contrib |
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped to the intended validation logic and align the checks with the stated ECMA/VM behavior without introducing new observable failure paths in the modified regions.
Pull request overview
Backports a Crossgen2 type-validation fix to release/10.0 so valid variant interfaces with type-owned generic constraints no longer fail variance validation (and thus can retain READYTORUN_FLAG_SkipTypeValidation for the intended perf optimization).
Changes:
- Expands interface method signature variance validation to cover all instance methods and all virtual methods (including static abstract/static virtual interface members).
- Removes the incorrect variance validation applied to a generic type’s own generic parameter constraints (per ECMA-335 II.9.7).
File summaries
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeValidationChecker.cs | Fixes Crossgen2 variance validation rules for type-owned constraints and broadens interface method signature checking to match VM behavior. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
JulieLeeMSFT
commented
Sep 3, 2026
/ba-g unrelated known issues. |
Backport of #132809 to release/10.0
Customer Impact
Crossgen2 applied method generic-constraint variance rules to a generic type's own constraints. ECMA-335 II.9.7 explicitly leaves type-owned constraints unrestricted, so valid variant interfaces could fail automatic validation and omit
READYTORUN_FLAG_SkipTypeValidation, disabling the perf optimization.This change:
Fixes#132724
Regression
Reduce types loaded on startup significantly #120459 introduced the regression.
Testing
Testing was done on
mainandrelease/11.0-rc1.release/10.0does not have the test project that the test was added to. The test project was manually built locally and contained the expectedREADYTORUN_FLAG_SkipTypeValidationflag.Risk
Low. The change makes the validation match the ECMA spec and matches the validation in the runtime.