Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c4d983f
Autogenerated tests for context hopping in Virtual static interface m…
davidwrighton Mar 25, 2021
a6ca485
Adjust line endings
davidwrighton Mar 25, 2021
1fc73ef
Refactor so that C# code is expressed as C# not as hand copied around IL
davidwrighton Mar 25, 2021
2eee539
Fix new lines
davidwrighton Mar 25, 2021
41811ca
Closer
davidwrighton Mar 25, 2021
635172f
Fixup expected strings
davidwrighton Mar 25, 2021
d0a2a13
Move reporting to C# code
davidwrighton Mar 25, 2021
a42a5fd
First pass at type hierarchy test
davidwrighton Mar 26, 2021
0815e4c
Fix the build
davidwrighton Mar 26, 2021
e5a9878
Add minimal covariant testing
davidwrighton Mar 29, 2021
3ea2dca
Add minimal test for initial bringup
davidwrighton Mar 29, 2021
26e949b
Fix issues discovered by Tomas
davidwrighton Apr 16, 2021
b7db7d2
Adjust test autogeneration based on spec tweaks
davidwrighton Apr 20, 2021
8589818
WIP: runtime support for static virtual interface methods (#2)
trylek Apr 20, 2021
93c9fb7
First version of method resolution - Scenario1-5 passing
trylek Apr 21, 2021
9e8be24
Desired change
davidwrighton Apr 22, 2021
4b0a75f
Add try and catch to TypeHierarchyTest
davidwrighton Apr 22, 2021
df39e61
First generic context tests pass
davidwrighton Apr 22, 2021
b045092
Handle generic methods (#4)
davidwrighton Apr 22, 2021
ddff311
60 TypeHierarchy tests passing via broader use of associated method d…
trylek Apr 23, 2021
9042354
Adjust generic dictionary to be able to resolve to a code pointer the…
davidwrighton Apr 26, 2021
b7d0917
Fix manipulation of signature type context in SVM resolution (#8)
trylek Apr 26, 2021
7d615d1
Fix GenericsContextTest test bugs (#10)
davidwrighton Apr 27, 2021
bb534b4
Fix type hierarchy tests (#11)
davidwrighton Apr 27, 2021
8f6f55e
- Pass thru allowInstParam flag from jit interface to TryResolveConst…
davidwrighton Apr 28, 2021
dc25f38
Add a selection of new handwritten IL tests (#14)
davidwrighton May 1, 2021
2360951
Fix remaining failing test issues in current testbed (#13)
davidwrighton May 1, 2021
4c460fa
Exclude SVM test generators from test build (#15)
trylek May 4, 2021
aa86d0a
Fix default interface method tests (#16)
trylek May 10, 2021
0caa786
Add support for interface variance (#18)
davidwrighton May 11, 2021
36f310f
Fix variance safety check (#19)
davidwrighton May 11, 2021
ab57767
Partial fix for the negative virtual static method tests (#17)
trylek May 12, 2021
00426d6
Fix bad merge
davidwrighton May 12, 2021
8eb54e6
Constraint checking (#20)
davidwrighton May 12, 2021
7cdf214
Fix issue where variance checking uses an unsafe contract by being mo…
davidwrighton May 12, 2021
43b0a96
Fix constraint check when a type variable is used to instantiate a ge…
davidwrighton May 13, 2021
28be21e
fix build break (#23)
davidwrighton May 13, 2021
dbea3da
Exempt static virtual method callers from Crossgen1/2 compilation (#24)
trylek May 14, 2021
211495a
Exclude static virtual method tests on Mono
trylek May 14, 2021
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
Prev Previous commit
Next Next commit
Fix issue where variance checking uses an unsafe contract by being mo…
…re strict in what we accept while verifying the type (#21)
  • Loading branch information
davidwrighton authored and trylek committed May 14, 2021
commit 7cdf214c9915fd2b271201270241e2fcb5a2b928
24 changes: 19 additions & 5 deletions src/coreclr/vm/methodtable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9201,7 +9201,7 @@ MethodDesc *MethodTable::GetDefaultConstructor(BOOL forceBoxedEntryPoint /* = FA
//==========================================================================================
// Finds the (non-unboxing) MethodDesc that implements the interface virtual static method pInterfaceMD.
MethodDesc *
MethodTable::ResolveVirtualStaticMethod(MethodTable* pInterfaceType, MethodDesc* pInterfaceMD, BOOL allowNullResult, BOOL checkDuplicates)
MethodTable::ResolveVirtualStaticMethod(MethodTable* pInterfaceType, MethodDesc* pInterfaceMD, BOOL allowNullResult, BOOL checkDuplicates, BOOL allowVariantMatches)
{
if (!pInterfaceMD->IsSharedByGenericMethodInstantiations() && !pInterfaceType->IsSharedByGenericInstantiations())
{
Expand Down Expand Up @@ -9237,7 +9237,7 @@ MethodTable::ResolveVirtualStaticMethod(MethodTable* pInterfaceType, MethodDesc*
return pMD;
}

if (pInterfaceType->HasVariance())
if (pInterfaceType->HasVariance() || pInterfaceType->HasTypeEquivalence())
{
// Variant interface dispatch
MethodTable::InterfaceMapIterator it = IterateInterfaceMap();
Expand All @@ -9252,12 +9252,26 @@ MethodTable::ResolveVirtualStaticMethod(MethodTable* pInterfaceType, MethodDesc*
if (!it.GetInterface()->HasSameTypeDefAs(pInterfaceType))
{
// Variance matches require a typedef match
// Equivalence isn't sufficient, and is uninteresting as equivalent interfaces cannot have static virtuals.
continue;
}

if (it.GetInterface()->CanCastTo(pInterfaceType, NULL))
BOOL equivalentOrVariantCompatible;

if (allowVariantMatches)
{
equivalentOrVariantCompatible = it.GetInterface()->CanCastTo(pInterfaceType, NULL);
}
else
{
// When performing override checking to ensure that a concrete type is valid, require the implementation
// actually implement the exact or equivalent interface.
equivalentOrVariantCompatible = it.GetInterface()->IsEquivalentTo(pInterfaceType, NULL);
}

if (equivalentOrVariantCompatible)
{
// Variant matching interface found
// Variant or equivalent matching interface found
// Attempt to resolve on variance matched interface
pMD = pMT->TryResolveVirtualStaticMethodOnThisType(it.GetInterface(), pInterfaceMD, checkDuplicates);
if (pMD != nullptr)
Expand Down Expand Up @@ -9418,7 +9432,7 @@ MethodTable::VerifyThatAllVirtualStaticMethodsAreImplemented()
MethodDesc *pMD = it.GetMethodDesc();
if (pMD->IsVirtual() &&
pMD->IsStatic() &&
!ResolveVirtualStaticMethod(pInterfaceMT, pMD, /* allowNullResult */ TRUE, /* checkDuplicates */ TRUE))
!ResolveVirtualStaticMethod(pInterfaceMT, pMD, /* allowNullResult */ TRUE, /* checkDuplicates */ TRUE, /* allowVariantMatches */ FALSE))
{
IMDInternalImport* pInternalImport = GetModule()->GetMDImport();
GetModule()->GetAssembly()->ThrowTypeLoadException(pInternalImport, GetCl(), pMD->GetName(), IDS_CLASSLOAD_STATICVIRTUAL_NOTIMPL);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/methodtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ class MethodTable


// Resolve virtual static interface method pInterfaceMD on this type.
MethodDesc *ResolveVirtualStaticMethod(MethodTable* pInterfaceType, MethodDesc* pInterfaceMD, BOOL allowNullResult, BOOL checkDuplicates = FALSE);
MethodDesc *ResolveVirtualStaticMethod(MethodTable* pInterfaceType, MethodDesc* pInterfaceMD, BOOL allowNullResult, BOOL checkDuplicates = FALSE, BOOL allowVariantMatches = TRUE);

// Try a partial resolve of the constraint call, up to generic code sharing.
//
Expand Down