Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/coreclr/vm/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1170,12 +1170,13 @@ void ClassLoader::ValidateMethodsWithCovariantReturnTypes(MethodTable* pMT)
continue;

// Locate the MethodTable defining the pParentMD.
while (pParentMT->GetCanonicalMethodTable() != pParentMD->GetMethodTable())
MethodTable* pDefinitionParentMT = pParentMT;
while (pDefinitionParentMT->GetCanonicalMethodTable() != pParentMD->GetMethodTable())
{
pParentMT = pParentMT->GetParentMethodTable();
pDefinitionParentMT = pDefinitionParentMT->GetParentMethodTable();
}

SigTypeContext context1(pParentMT->GetInstantiation(), pMD->GetMethodInstantiation());
SigTypeContext context1(pDefinitionParentMT->GetInstantiation(), pMD->GetMethodInstantiation());
MetaSig methodSig1(pParentMD);
TypeHandle hType1 = methodSig1.GetReturnProps().GetTypeHandleThrowing(pParentMD->GetModule(), &context1, ClassLoader::LoadTypesFlag::LoadTypes, CLASS_LOAD_EXACTPARENTS);

Expand Down
32 changes: 32 additions & 0 deletions src/tests/Regressions/coreclr/GitHub_54719/test54719.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;

public class IA { }
public class IB { }

public abstract class Base
{
public abstract IA Key { get; }
public abstract IB Value { get; }
}
public sealed class Derived : Base<IB>
{
public class A : IA { }
public sealed override A Key => default;
}
public abstract class Base<B> : Base where B : IB
{
public sealed override B Value => null;
}

class Program
{
static int Main()
{
new Derived();

return 100;
}
}
10 changes: 10 additions & 0 deletions src/tests/Regressions/coreclr/GitHub_54719/test54719.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<CLRTestKind>BuildAndRun</CLRTestKind>
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<ItemGroup>
<Compile Include="test54719.cs" />
</ItemGroup>
</Project>