diff --git a/src/coreclr/src/vm/class.cpp b/src/coreclr/src/vm/class.cpp index 0f398b93c6cce..e8b39c00b606d 100644 --- a/src/coreclr/src/vm/class.cpp +++ b/src/coreclr/src/vm/class.cpp @@ -1169,6 +1169,12 @@ void ClassLoader::ValidateMethodsWithCovariantReturnTypes(MethodTable* pMT) if (!pMD->RequiresCovariantReturnTypeChecking() && !pParentMD->RequiresCovariantReturnTypeChecking()) continue; + // Locate the MethodTable defining the pParentMD. + while (pParentMT->GetCanonicalMethodTable() != pParentMD->GetMethodTable()) + { + pParentMT = pParentMT->GetParentMethodTable(); + } + SigTypeContext context1(pParentMT->GetInstantiation(), pMD->GetMethodInstantiation()); MetaSig methodSig1(pParentMD); TypeHandle hType1 = methodSig1.GetReturnProps().GetTypeHandleThrowing(pParentMD->GetModule(), &context1, ClassLoader::LoadTypesFlag::LoadTypes, CLASS_LOAD_EXACTPARENTS); diff --git a/src/tests/Regressions/coreclr/GitHub_45053/test45053.cs b/src/tests/Regressions/coreclr/GitHub_45053/test45053.cs new file mode 100644 index 0000000000000..1c093f6ee2924 --- /dev/null +++ b/src/tests/Regressions/coreclr/GitHub_45053/test45053.cs @@ -0,0 +1,39 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; + +public abstract class T