Fix `getMethodSig` for array methods (#81942)
authorMichal Strehovský <MichalStrehovsky@users.noreply.github.com>
Fri, 10 Feb 2023 14:43:15 +0000 (23:43 +0900)
committerGitHub <noreply@github.com>
Fri, 10 Feb 2023 14:43:15 +0000 (06:43 -0800)
Found by JIT tests. This also affects crossgen2, wonder why we haven't seen it.

src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs

index c092df8..fbb17f2 100644 (file)
@@ -1151,12 +1151,19 @@ namespace Internal.JitInterface
                 // supplied by RyuJIT is a concrete instantiation.
                 if (type != method.OwningType)
                 {
-                    Debug.Assert(type.HasSameTypeDefinition(method.OwningType));
-                    Instantiation methodInst = method.Instantiation;
-                    method = _compilation.TypeSystemContext.GetMethodForInstantiatedType(method.GetTypicalMethodDefinition(), (InstantiatedType)type);
-                    if (methodInst.Length > 0)
+                    if (type.IsArray)
                     {
-                        method = method.MakeInstantiatedMethod(methodInst);
+                        method = ((ArrayType)type).GetArrayMethod(((ArrayMethod)method).Kind);
+                    }
+                    else
+                    {
+                        Debug.Assert(type.HasSameTypeDefinition(method.OwningType));
+                        Instantiation methodInst = method.Instantiation;
+                        method = _compilation.TypeSystemContext.GetMethodForInstantiatedType(method.GetTypicalMethodDefinition(), (InstantiatedType)type);
+                        if (methodInst.Length > 0)
+                        {
+                            method = method.MakeInstantiatedMethod(methodInst);
+                        }
                     }
                 }
             }