Description
I assume this is a regression from #51764.
In the \src\tests\JIT\Generics\Instantiation\Interfaces\Class05.cs test, we have a situation where:
public interface IGen<T>
{
void _Init(T fld1);
bool InstVerify(System.Type t1);
}
public interface IGenSub2DStringArray : IGen<string[,]> { }
public class Gen2DStringArray : IGenSub2DStringArray
{
public void _Init(string[,] fld1)
{
}
}
When the managed type system tries to find implementation of IGen<string[]>._Init
on Gen2DStringArray
, it will try to match up the signature of _Init
between those two types. The signatures don't match because the signature of _Init
on Gen2DStringArray
has EmbeddedSignatureData of type ArrayShape with contents 1.2.2.1||0,0
, while the signature on the interface doesn't have an ArrayShape. The Equals check on the signature fails at callstack:
> ILCompiler.TypeSystem.dll!Internal.TypeSystem.MethodSignature.Equals(Internal.TypeSystem.MethodSignature otherSignature, bool allowCovariantReturn) Line 220 C#
ILCompiler.TypeSystem.dll!Internal.TypeSystem.MethodSignature.Equals(Internal.TypeSystem.MethodSignature otherSignature) Line 185 C#
ILCompiler.TypeSystem.dll!Internal.TypeSystem.MetadataVirtualMethodAlgorithm.FindMatchingVirtualMethodOnTypeByNameAndSig(Internal.TypeSystem.MethodDesc targetMethod, Internal.TypeSystem.DefType currentType, bool reverseMethodSearch, System.Func<Internal.TypeSystem.MethodDesc, Internal.TypeSystem.MethodDesc, bool> nameSigMatchMethodIsValidCandidate) Line 340 C#
ILCompiler.TypeSystem.dll!Internal.TypeSystem.MetadataVirtualMethodAlgorithm.ResolveInterfaceMethodToVirtualMethodOnType(Internal.TypeSystem.MethodDesc interfaceMethod, Internal.TypeSystem.MetadataType currentType) Line 601 C#
ILCompiler.TypeSystem.dll!Internal.TypeSystem.MetadataVirtualMethodAlgorithm.ResolveInterfaceMethodToVirtualMethodOnType(Internal.TypeSystem.MethodDesc interfaceMethod, Internal.TypeSystem.TypeDesc currentType) Line 565 C#
ILCompiler.TypeSystem.dll!Internal.TypeSystem.TypeSystemHelpers.ResolveInterfaceMethodToVirtualMethodOnType(Internal.TypeSystem.TypeDesc type, Internal.TypeSystem.MethodDesc interfaceMethod) Line 275 C#
There are more tests where this is failing, but I assume in crossgen2 this only means a failure to devirtualize in these tests. The failure mode is more brutal in NativeAOT.
But this can result in incorrect devirtualization with crossgen2 if there's a matching signature in one of the base types - I assume we don't have tests for that.
Cc @dotnet/crossgen-contrib