Skip to content

Revert "Handle canonical types in casting logic"#127301

Merged
MichalStrehovsky merged 1 commit intomainfrom
revert-127146-fix126604
Apr 23, 2026
Merged

Revert "Handle canonical types in casting logic"#127301
MichalStrehovsky merged 1 commit intomainfrom
revert-127146-fix126604

Conversation

@MichalStrehovsky
Copy link
Copy Markdown
Member

@MichalStrehovsky MichalStrehovsky commented Apr 22, 2026

Resolves #127259

Reverts #127146

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts #127146, removing recently-added canonical type handling in the CoreCLR NativeAOT TypeSystem casting/constraint logic and backing out the associated tests.

Changes:

  • Remove canonical-type-aware casting/constraint helpers and related normalization in dataflow handling.
  • Remove unit tests and smoke test coverage that were added to validate canonical type behavior.
  • Update project files to stop compiling the reverted Canon/NonCanon helper sources.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/tests/nativeaot/SmokeTests/TrimmingBehaviors/Dataflow.cs Removes a trimming smoke test case that exercised constrained generic MakeGenericType behavior.
src/coreclr/tools/aot/ILCompiler.TypeSystem/ILCompiler.TypeSystem.csproj Stops including Canon helper sources that were added in the reverted change.
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/CoreTestAssembly/GenericConstraints.cs Removes test types used only by the reverted canonical constraints tests.
src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ConstraintsValidationTest.cs Removes the canonical constraints validation test method.
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/HandleCallAction.cs Removes instantiation normalization that was added for canonical shapes prior to constraint checking.
src/coreclr/tools/ILVerification/ILVerification.projitems Removes NonCanon helper compile items that were introduced by the reverted change.
src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.cs Reverts canonical-type constraint handling (and removes partial split support used by the reverted change).
src/coreclr/tools/Common/TypeSystem/Common/TypeSystemConstraintsHelpers.NonCanon.cs Deletes the NonCanon stub file introduced by the reverted change.
src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.cs Reverts canonical-type casting logic additions.
src/coreclr/tools/Common/TypeSystem/Common/CastingHelper.NonCanon.cs Deletes the NonCanon stub file introduced by the reverted change.
src/coreclr/tools/Common/TypeSystem/Canon/TypeSystemConstraintsHelpers.Canon.cs Deletes the Canon implementation file introduced by the reverted change.
src/coreclr/tools/Common/TypeSystem/Canon/CastingHelper.Canon.cs Deletes the Canon implementation file introduced by the reverted change.
src/coreclr/nativeaot/System.Private.TypeLoader/src/System.Private.TypeLoader.csproj Stops including Canon casting helper source introduced by the reverted change.

jkotas

This comment was marked as resolved.

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

What's wrong with the fix?

It doesn't match CanCastTo in the VM: #127259 (comment) and it would be preferable to have it match. I started #127146 with the logic not being in the CanCastTo (the first commit has that), but copilot wasn't able to come up with anything reliable (the first commit was not oneshotted, this took like 4 iterations of me pointing out flaws in it and it adding tests and fixing the bugs). Then I lost confidence in being able to do it reliably there and moved it to CanCastTo (that one was pretty much oneshotted). I'll need to think about what to do here (hence the revert so that there's no time pressure).

@MichalStrehovsky
Copy link
Copy Markdown
Member Author

/ba-g there's some Helix service bus issues, but this is just a revert from a couple dozen hours ago and relevant native AOT legs passes. we should not ship preview 4 with this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test failure: JIT/opt/Casts/shared_Casts/shared_Casts.dll

3 participants