Skip to content

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

@jakobbotsch

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.

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