You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 2. It is a special marker type, AND pNewItfMT is a special marker type. Compute the exact instantiation as containing entirely a list of types corresponding to calling GetSpecialInstantiationType on pMT (This rule works based on the current behavior of GetSpecialInstantiationType where it treats all interfaces the same)
9675
+
// 3. It is a special marker type, but pNewItfMT is NOT a special marker type. Compute the exact instantiation as containing entirely a list of types corresponding to calling GetSpecialInstantiationType on pNewItfMT
9676
+
// 4. It is an exact instantiation
9677
+
//
9678
+
// NOTE: pItfPossiblyApprox must not be considered a special marker type if pNewItfMT has the MayHaveOpenInterfacesInInterfaceMap flag set
9679
+
//
9680
+
// Then determine if all of the following conditions hold true.
9681
+
// 1. All generic arguments are the same (always true for cases 2 and 3 above)
9682
+
// 2. The first generic argument in the instantiation is exactly the value of calling GetSpecialInstantiationType on pMT (always true for case 2)
9683
+
//
9684
+
// If so, then we should insert the special marker type
9685
+
// Otherwise, we should insert the exact instantiation of the interface
9686
+
// HOWEVER: If the exact instantiation IS a special marker interface, we need to retry with exact interfaces to avoid ambiguity situations
9687
+
//
9688
+
// NOTE: This is also part of the logic which determines if we need to call SetMayHaveOpenInterfacesInInterfaceMap. The CLR type system has a bug in its structure
9689
+
// such that if you attempt to instantiate a type over its own type parameter from the open type, we will load the GenericTypeDefinition instead of loading
9690
+
// a type explicitly instantiated over those type parameters. We re-use the GenericTypeDefinition as the special marker type, which leads to a conflict
9691
+
// when something like that happens. So, we need to detect when something like that happens, and set the MayHaveOpenInterfacesInInterfaceMap flag,
9692
+
// and avoid using the special marker type in those situations.
9693
+
MethodTable *pItfToInsert = NULL;
9694
+
bool intendedExactMatch = false;
9695
+
9696
+
if (!pItfPossiblyApprox->HasInstantiation())
9697
+
{
9698
+
// case 1
9699
+
pItfToInsert = pItfPossiblyApprox;
9700
+
intendedExactMatch = true;
9701
+
}
9702
+
else if (pItfPossiblyApprox->IsSpecialMarkerTypeForGenericCasting() && !pNewIntfMT->GetAuxiliaryData()->MayHaveOpenInterfacesInInterfaceMap())
if (ClassLoader::EligibleForSpecialMarkerTypeUsage(pItfPossiblyApprox->GetInstantiation(), pMT))
9730
+
{
9731
+
// Validated that all generic arguments are the same, and that the first generic argument in the instantiation is exactly the value of calling GetSpecialInstantiationType on pMT
if (pItfToInsert->IsSpecialMarkerTypeForGenericCasting())
9743
+
{
9744
+
if (intendedExactMatch)
9745
+
{
9746
+
// We are trying to insert a special marker type into the interface list, but it is exactly the same as the exact instantiation we should actually want, we need to set the
9747
+
// MayHaveOpenInterfacesInInterfaceMap flag, so trigger the retry logic.
9748
+
retry = true;
9749
+
break;
9750
+
}
9751
+
else if (pMT->GetSpecialInstantiationType() == pItfToInsert->GetInstantiation()[0])
9752
+
{
9753
+
// We are trying to insert a special marker type into the interface list, but the first generic argument
9754
+
// in the instantiation is exactly the value of calling GetSpecialInstantiationType on pMT.
9755
+
// This implies that the special marker type is actually the exact instantiation that we should be using, which
9756
+
// will cause the same ambiguity situation as above. Trigger a retry, which will set MayHaveOpenInterfacesInInterfaceMap
9757
+
// and disable the special marker type behavior for this type.
0 commit comments