Skip to content

Implementation of a static virtual method in a derived type is not found when there is a re-abstraction of the same method higher in inheritance hierarchy  #80350

@AlekseyTs

Description

@AlekseyTs

Description

Implementation of a static virtual method in a derived type is not found when there is a re-abstraction of the same method higher in inheritance hierarchy

Reproduction Steps

https://sharplab.io/#v2:C4LgTgrgdgPgAgJgAQBUCmBnYBGJIkCSCAsAFADeZZSNSc2AbHQCxICyAhgJZQAUAlNVqVStMakzAAPOizYAfAIDcQmgF8qo2vSZxWs6VwUCkAdwAWaMGiRG8hbKqQinYowDo22ZU42knOiwOnt6CWjQi4trY7vQAnLwARAYxXon8KuFIfn5kcADMtlDAVgBmHADGNgSOFAGMSBwARlhglcBBXj6kuaQFRSVg5VWEyPg1ZJHRTM2t7UE1Id1+QA=

Compile and run:

class Test1 : I2
{

    static void Main()
    {
        Test<Test1>();
    }

    static void Test<i1>() where i1 : I1
    {

        i1.M1();
    }

    static void I1.M1()
    {
        System.Console.WriteLine("Test1.M1");
    }
}

public interface I1
{
    static abstract void M1();
}

public interface I2 : I1
{
    static abstract void I1.M1();
}

Expected behavior

"Test1.M1" is printed

Actual behavior

System.MissingMethodException: Method not found: 'Void I1.M1()'.
at System.Reflection.RuntimeAssembly.get_EntryPoint()
at SharpLab.Container.Execution.ExecuteCommandHandler.ExecuteAssembly(Byte[] assemblyBytes) in

Regression?

No response

Known Workarounds

Remove re-abstraction of the method in I2 to observe expected behavior.

Configuration

No response

Other information

Here is another flavor of the problem:
https://sharplab.io/#v2:C4LgTgrgdgPgAgJgAQBUCmBnYBGJIkCSAzALABQA3ueUrUnNgGz0AsSAsgIYCWUAFAEoadKmTrjUmYAB50WbAD5BAbmG0AvtTF0GzOGzkzuiwUgDuACzRg0SY3kLY1SUc/HGAdO2wrnmsv7kcER2UMDWAGacAMa2BE6UzrpInABGWGAxwKwcPgKqAVrBoeFgUbGEyPjx5KLiyWkZWTnxXnkFgWTFvKXlcSHVCLVJTC3YbYLOdRK0DB4MAJx8AETEbcv5fuT+QA==

class Test1 : I3
{

    static void Main()
    {
        Test<Test1>();
    }

    static void Test<i1>() where i1 : I1
    {

        i1.M1();
    }
}

public interface I1
{
    static abstract void M1();
}

public interface I2 : I1
{
    static abstract void I1.M1();
}

public interface I3 : I2
{
    static void I1.M1()
    {
        System.Console.WriteLine("I3.M1");
    }
}

Expected:

I3.M1

Actual:

System.MissingMethodException: Method not found: 'Void I1.M1()'.
   at System.Reflection.RuntimeAssembly.get_EntryPoint()
   at SharpLab.Container.Execution.ExecuteCommandHandler.ExecuteAssembly(Byte[] assemblyBytes) in 

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions