Fix covariant returns when overriding method of non-parent ancestor (#47846)
authorJan Vorlicek <jan.vorlicek@volny.cz>
Fri, 5 Feb 2021 09:34:34 +0000 (10:34 +0100)
committerGitHub <noreply@github.com>
Fri, 5 Feb 2021 09:34:34 +0000 (10:34 +0100)
commitc7c734e2828119035a4474fa6e74e73769d992db
tree4e0849b8f4239df7ba8fff92c9f249fdbfff97f5
parent5077dd45417cfe64e800930568d0301ec7ffad6d
Fix covariant returns when overriding method of non-parent ancestor (#47846)

There is a problem in the
ClassLoader::ValidateMethodsWithCovariantReturnTypes that results in
failed verification of valid override in case the return type of the
method being overriden is generic in canonical form and it is defined
in an ancestor class that is not the parent.

The problem is that we attempt to use instantiation of the parent class
instead of the ancestor class that contains definition of the method
being overriden.

This change fixes it by locating the proper ancestor MethodTable and
using it.
src/coreclr/vm/class.cpp
src/tests/Regressions/coreclr/GitHub_45053/test45053.cs [new file with mode: 0644]
src/tests/Regressions/coreclr/GitHub_45053/test45053.csproj [new file with mode: 0644]