The logic in MethodTable::FindDefaultInterfaceImplementation around this code:
https://github.com/dotnet/coreclr/blob/24680bd7883a1f8424766c5196b96b803dfb796d/src/vm/methodtable.cpp#L7171-L7184
Uses the instantiation of the IBar interface in pCurMT (that is not generic) to load IFoo`1. This should likely use a different strategy to iterate the methodimpls.
.assembly extern System.Runtime { }
.assembly unambiguousconstraint { }
.class interface private abstract auto ansi IFoo`1<T>
{
.method public hidebysig newslot abstract virtual instance int32 Frob() cil managed
{
}
}
.class interface private abstract auto ansi IBar
implements class IFoo`1<class [System.Runtime]System.Object>
{
.method public hidebysig newslot virtual final instance int32 Frob() cil managed
{
.override class IFoo`1<class [System.Runtime]System.Object>::Frob
ldc.i4.m1
ret
}
}
.class interface private abstract auto ansi IBaz
implements class IFoo`1<class [System.Runtime]System.String>
{
.method public hidebysig newslot virtual final instance int32 Frob() cil managed
{
.override class IFoo`1<class [System.Runtime]System.String>::Frob
ldc.i4 100
ret
}
}
.class private auto ansi beforefieldinit Fooer
extends [System.Runtime]System.ValueType
implements IBar, IBaz
{
}
.class private auto ansi beforefieldinit Gen`1<(class IFoo`1<class [System.Runtime]System.String>) T>
extends [System.Runtime]System.Object
{
.method public hidebysig static int32 Check(!T x) cil managed
{
ldarga.s 0
constrained. !T
callvirt instance int32 class IFoo`1<class [System.Runtime]System.String>::Frob()
ret
}
}
.method public hidebysig static int32 Main() cil managed
{
.entrypoint
.locals init (valuetype Fooer)
ldloc.0
call int32 class Gen`1<valuetype Fooer>::Check(!0)
ret
}
The logic in
MethodTable::FindDefaultInterfaceImplementationaround this code:https://github.com/dotnet/coreclr/blob/24680bd7883a1f8424766c5196b96b803dfb796d/src/vm/methodtable.cpp#L7171-L7184
Uses the instantiation of the
IBarinterface inpCurMT(that is not generic) to loadIFoo`1. This should likely use a different strategy to iterate the methodimpls.