mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Extension check refinements, more extension tests
This commit is contained in:
parent
f0a6ec4870
commit
2d4cc6d86e
4 changed files with 42 additions and 40 deletions
|
@ -212,6 +212,9 @@ void BfMethodMatcher::Init(/*SizedArrayImpl<BfResolvedArg>& arguments, */BfSized
|
||||||
|
|
||||||
bool BfMethodMatcher::IsMemberAccessible(BfTypeInstance* typeInst, BfTypeDef* declaringType)
|
bool BfMethodMatcher::IsMemberAccessible(BfTypeInstance* typeInst, BfTypeDef* declaringType)
|
||||||
{
|
{
|
||||||
|
if (!declaringType->mIsPartial)
|
||||||
|
return true;
|
||||||
|
|
||||||
if (mActiveTypeDef == NULL)
|
if (mActiveTypeDef == NULL)
|
||||||
mActiveTypeDef = mModule->GetActiveTypeDef();
|
mActiveTypeDef = mModule->GetActiveTypeDef();
|
||||||
|
|
||||||
|
|
|
@ -2913,8 +2913,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
|
SetAndRestoreValue<BfFieldDef*> prevTypeRef(mContext->mCurTypeState->mCurFieldDef, fieldDef);
|
||||||
bool populateChildType = !typeInstance->mTypeFailed;
|
bool populateChildType = !typeInstance->mTypeFailed;
|
||||||
//bool populateChildType = true;
|
//bool populateChildType = true;
|
||||||
PopulateType(resolvedFieldType, populateChildType ? BfPopulateType_Data : BfPopulateType_Declaration);
|
PopulateType(resolvedFieldType, populateChildType ? BfPopulateType_Data : BfPopulateType_Declaration);
|
||||||
BF_ASSERT(!typeInstance->mNeedsMethodProcessing);
|
|
||||||
|
|
||||||
if (populateChildType)
|
if (populateChildType)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2093,9 +2093,7 @@ bool BfTypeInstance::IsTypeMemberIncluded(BfTypeDef* typeDef, BfTypeDef* activeT
|
||||||
return true;
|
return true;
|
||||||
if ((typeDef == NULL) || (typeDef == activeTypeDef))
|
if ((typeDef == NULL) || (typeDef == activeTypeDef))
|
||||||
return true;
|
return true;
|
||||||
if (typeDef->mTypeDeclaration == mTypeDef->mTypeDeclaration)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// The combined type declaration is the root type declaration, it's implicitly included
|
// The combined type declaration is the root type declaration, it's implicitly included
|
||||||
if (typeDef->mTypeDeclaration == mTypeDef->mTypeDeclaration)
|
if (typeDef->mTypeDeclaration == mTypeDef->mTypeDeclaration)
|
||||||
return true;
|
return true;
|
||||||
|
@ -2125,43 +2123,13 @@ bool BfTypeInstance::IsTypeMemberIncluded(BfTypeDef* typeDef, BfTypeDef* activeT
|
||||||
genericArg = declGenericParam->mExternType;
|
genericArg = declGenericParam->mExternType;
|
||||||
}
|
}
|
||||||
|
|
||||||
//auto genericType = mGenericTypeInfo->mTypeGenericArguments[genericIdx];
|
|
||||||
|
|
||||||
if ((genericArg == NULL) || (!module->CheckGenericConstraints(BfGenericParamSource(), genericArg, NULL, declGenericParam)))
|
if ((genericArg == NULL) || (!module->CheckGenericConstraints(BfGenericParamSource(), genericArg, NULL, declGenericParam)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//if (!mModule->AreConstraintsSubset((*declConstraints)[genericIdx], (*activeConstraints)[genericIdx]))
|
|
||||||
//isSubset = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/*else if ((mIsUnspecialized) && (activeTypeDef != NULL))
|
|
||||||
{
|
|
||||||
auto subsetItr = genericExEntry->mConstraintSubsetMap.find(activeTypeDef);
|
|
||||||
if (subsetItr != genericExEntry->mConstraintSubsetMap.end())
|
|
||||||
{
|
|
||||||
return subsetItr->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto declConstraints = &genericExEntry->mGenericParams;
|
|
||||||
auto activeConstraints = GetGenericParamsVector(activeTypeDef);
|
|
||||||
|
|
||||||
bool isSubset = true;
|
|
||||||
for (int genericIdx = 0; genericIdx < (int)declConstraints->size(); genericIdx++)
|
|
||||||
{
|
|
||||||
if (!mModule->AreConstraintsSubset((*declConstraints)[genericIdx], (*activeConstraints)[genericIdx]))
|
|
||||||
isSubset = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We can't cache this because the meaning of the params may change, IE: TypeName<@M0> needs to consider the
|
|
||||||
// constraints of @M0 for each method it is checked against
|
|
||||||
if (!IsUnspecializedTypeVariation())
|
|
||||||
genericExEntry->mConstraintSubsetMap[activeTypeDef] = isSubset;
|
|
||||||
|
|
||||||
return isSubset;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
return genericExEntry->mConstraintsPassed;
|
return genericExEntry->mConstraintsPassed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,26 @@ namespace Tests
|
||||||
public int32 mB;
|
public int32 mB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ClassB : IHashable
|
||||||
|
{
|
||||||
|
public int32 mA;
|
||||||
|
|
||||||
|
public this(int32 a)
|
||||||
|
{
|
||||||
|
mA = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool operator==(ClassB lhs, ClassB rhs)
|
||||||
|
{
|
||||||
|
return lhs.mA == rhs.mA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode()
|
||||||
|
{
|
||||||
|
return mA;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class TClassA<T> where T : IDisposable
|
class TClassA<T> where T : IDisposable
|
||||||
{
|
{
|
||||||
public int32 mA = 10;
|
public int32 mA = 10;
|
||||||
|
@ -185,11 +205,23 @@ namespace Tests
|
||||||
[Test]
|
[Test]
|
||||||
public static void TestDictionary()
|
public static void TestDictionary()
|
||||||
{
|
{
|
||||||
Dictionary<String, int> dictLhs = scope .() {("Abc", 123), ("Def", 234) };
|
Dictionary<String, int> dictLhs = scope .() { ("Abc", 123), ("Def", 234) };
|
||||||
Dictionary<String, int> dictrhs = scope .() {(scope:: String("Abc"), 123), ("Def", 234) };
|
Dictionary<String, int> dictRhs = scope .() { (scope:: String("Abc"), 123), ("Def", 234) };
|
||||||
|
|
||||||
Test.Assert(dictLhs == dictrhs);
|
Test.Assert(dictLhs == dictRhs);
|
||||||
Test.Assert(!LibA.LibA0.DictEquals(dictLhs, dictrhs));
|
Test.Assert(!LibA.LibA0.DictEquals(dictLhs, dictRhs));
|
||||||
|
|
||||||
|
Dictionary<String, int>[2] dictArrLhs = .(dictLhs, dictLhs);
|
||||||
|
Dictionary<String, int>[2] dictArrRhs = .(dictRhs, dictRhs);
|
||||||
|
Test.Assert(dictArrLhs != dictArrRhs);
|
||||||
|
|
||||||
|
Dictionary<ClassB, int> dictLhs2 = scope .() { (scope:: ClassB(111), 123) };
|
||||||
|
Dictionary<ClassB, int> dictRhs2 = scope .() { (scope:: ClassB(111), 123) };
|
||||||
|
Test.Assert(dictLhs2 == dictRhs2);
|
||||||
|
|
||||||
|
Dictionary<ClassB, int>[2] dictArrLhs2 = .(dictLhs2, dictLhs2);
|
||||||
|
Dictionary<ClassB, int>[2] dictArrRhs2 = .(dictRhs2, dictRhs2);
|
||||||
|
Test.Assert(dictArrLhs2 == dictArrRhs2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue