-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
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
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