You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider type declaration order in MethodImpls (#111998)
This fixes the Loader\classloader\InterfaceFolding\Ambiguous test.
For the following program in pseudo-C# (test is in IL since this is not valid C#):
```csharp
B<int, int> b = new B<int, int>();
if (!(((I<int>)b).Foo() != "B::Foo2"))
{
B<string, string> b2 = new B<string, string>();
if (!(((I<string>)b2).Foo() != "B::Foo2"))
{
Console.WriteLine("Pass");
return 100;
}
}
Console.WriteLine("Failed!");
return -1;
interface I<T>
{
string Foo();
}
class A<U> : I<U>
{
string I<U>.Foo() => "A::Foo";
}
internal class B<V, W> : A<V>, I<W>
{
string I<W>.Foo() => "B::Foo1";
string I<V>.Foo() => "B::Foo2";
}
```
We incorrectly resolve the interface call into `B::Foo1` because `I<int>.Foo` could be implemented by both `Foo1` and `Foo2` methods and we just pick whatever we see first. Per ECMA-335: "If there are multiple methods for the same interface method (i.e. with different generic type parameters), place them in the list in type declaration order of the associated interfaces."
This implements the tie break.
0 commit comments