Open types can exist as entries in interface map (#55372)
authorDavid Wrighton <davidwr@microsoft.com>
Tue, 13 Jul 2021 22:25:10 +0000 (15:25 -0700)
committerGitHub <noreply@github.com>
Tue, 13 Jul 2021 22:25:10 +0000 (15:25 -0700)
commit002370bd1b2d848dcf65ef11cf6b2f4592a6fb89
treed27cf34e9126f12a56b0ce76aa0344963d5334aa
parentf5316845d5a0069f1b265b5f6d3b81b827450737
Open types can exist as entries in interface map (#55372)

* Open types can exist as entries in interface map
- While invalid via the ECMA spec, the runtime currently represents a type explicitly instantiated over its own generic type parameters via the open type MethodTable
- This is not strictly correct, as per the spec, these should be represented via an instantiated type, but changing that detail at this time is considered highly risky
- This conflicts with the perf optimization around partialy interface loading which uses the open type of an interface to represent a type instantiated in the curiously recurring fashion.
- The fix is to detect types instantiated over generic variables, and make them ineligible for the optimization, and to detect those cases where the optimization is ineligible, and revert back to the non-optimized behavior

Fixes #55323
src/coreclr/vm/methodtable.cpp
src/coreclr/vm/methodtable.h
src/coreclr/vm/methodtable.inl
src/coreclr/vm/methodtablebuilder.cpp
src/tests/Loader/classloader/generics/Instantiation/Positive/CuriouslyRecurringThroughInterface.cs [new file with mode: 0644]
src/tests/Loader/classloader/generics/Instantiation/Positive/CuriouslyRecurringThroughInterface.csproj [new file with mode: 0644]