Skip to content

TypeEqualitySealed test is failing with full trimming on #121874

Closed

Description

@MichalStrehovsky

in pull request #121697, I'm seeing this line:

[MethodImpl(MethodImplOptions.NoInlining)]
public static object TestTernary8(SealedClass1 instance) => instance.GetType() == typeof(SealedClass2) ? "Fail" : "Ok";

Optimized to:

00007FF63D852FF0  lea         rax,[__Str_Ok (07FF63D88B278h)]  
00007FF63D852FF7  ret  

What is probably happening is that with trimming disabled, whole program analysis sees SealedClass2 as possible (because we reflection-rooted it), however after allowing trimming, it becomes impossible and we forget about the NRE side effect.

To repro, you can just copy paste the C# source into the Visual Studio repro project and add -O to the ILC command line. Delete the Xunit gunk and rename the Fact method to Main.

Cc @EgorBo

Activity

  1. added
    area-CodeGen-coreclr
    on Nov 21, 2025
  2. added
    untriaged
    on Nov 21, 2025
  3. dotnet-policy-service commented on Nov 21, 2025

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
    See info in area-owners.md if you want to be subscribed.

  4. self-assigned this
    on Nov 21, 2025
  5. added this to the 11.0.0 milestone on Nov 21, 2025
  6. removed
    untriaged
    on Nov 21, 2025
  7. EgorBo commented on Nov 21, 2025

    @EgorBo
    Member

    Good catch! Filed #121875

  8. locked and limited conversation to collaborators on Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions