Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

#123112 started running more outerloop tests, including:

public static class Repro
{
private static bool CheckType(Action<string> a)
{
return a.GetType() == typeof(Action<object>);
}
[Fact]
[OuterLoop]
public static int TestEntryPoint()
{
Action<string> a = (Action<object>)Console.WriteLine;
if (CheckType(a))
{
Console.WriteLine("pass");
return 100;
}
Console.WriteLine("FAIL");
return 101;
}
}

We were incorrectly optimizing the a.GetType() == typeof(Action<object>) check to false (type of the parameter is Action<string> and JIT was asking for exact classes of Action<string>; and there are none).

Cc @dotnet/ilc-contrib @EgorBo

#123112 started running more outerloop tests, including: https://github.com/dotnet/runtime/blob/81e28e28a7dd0c5109f8a3c0e458d3de577e78f8/src/tests/JIT/Methodical/flowgraph/dev10_bug679008/sealedCastVariance.cs#L13-L32

We were incorrectly optimizing the `a.GetType() == typeof(Action<object>)` check to `false` (type of the parameter is `Action<string>` and JIT was asking for exact classes of `Action<string>`; and there are none).
Copilot AI review requested due to automatic review settings January 22, 2026 08:11
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jan 22, 2026
@MichalStrehovsky MichalStrehovsky added area-NativeAOT-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 22, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib
See info in area-owners.md if you want to be subscribed.

Copy link
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 fixes an incorrect JIT optimization for variant types by adding a variance check to the getExactClasses method. The issue was discovered when outerloop tests started running after PR #123112, specifically the sealedCastVariance.cs test which validates type checks on variant delegate types.

Changes:

  • Modified getExactClasses to return -1 (indicating uncertainty) for types with variance, preventing the JIT from making incorrect type assumptions

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.

4 participants