Skip to content

Static virtual calls go through task-returning thunks always #124545

Closed

Description

@jakobbotsch

Example from @MichalStrehovsky:

using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Xunit;

public class StaticVirtual
{
    interface IHaveStaticVirtuals
    {
        static abstract Task DoTask();
    }

    class ClassWithStaticVirtuals : IHaveStaticVirtuals
    {
        public static async Task DoTask() => await Task.Yield();
    }

    static async Task CallDoTask<T>() where T : IHaveStaticVirtuals => await T.DoTask();

    [Fact]
    public static void TestEntryPoint()
    {
        CallDoTask<ClassWithStaticVirtuals>().Wait();
    }
}

We see task-returning thunk created for DoTask. This is a regression introduced by #124283. We do not properly detect that this is a virtual call.

Activity

  1. self-assigned this
    on Feb 18, 2026
  2. added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Feb 18, 2026
  3. added this to the 11.0.0 milestone on Feb 18, 2026
  4. dotnet-policy-service commented on Feb 18, 2026

    @dotnet-policy-service
    Contributor

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

  5. jakobbotsch commented on Feb 18, 2026

    @jakobbotsch
    MemberAuthor

    I think we'll want to move the logic that resolves async variants from resolveToken to getCallInfo. resolveToken does not have all the information available it needs to make a good determination about whether the call will be direct or not (specifically for constrained calls).

  6. added a commit that references this issue on Feb 24, 2026
    097b378
  7. added a commit that references this issue on Feb 28, 2026
    aba6825
  8. locked and limited conversation to collaborators on Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions