1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 20:42:21 +02:00

More sophisticated Self equality check (ie: 'Result<Self>')

This commit is contained in:
Brian Fiete 2022-01-16 08:00:57 -05:00
parent c6ca4c8bb4
commit 913d60ef5b

View file

@ -4940,12 +4940,18 @@ String BfTypeUtils::TypeToString(BfAstNode* typeRefNode)
return typeRef->ToString();
}
bool BfTypeUtils::TypeEquals(BfType* typeA, BfType* typeB, BfType* selfType)
bool BfTypeUtils::TypeEquals(BfType* typeA, BfType* typeB, BfTypeInstance* selfType)
{
if (typeA->IsSelf())
typeA = selfType;
if (typeB->IsSelf())
typeB = selfType;
if (typeA->IsUnspecializedTypeVariation())
{
SetAndRestoreValue<BfTypeInstance*> prevCurTypeInst(selfType->mModule->mCurTypeInstance, selfType);
return selfType->mModule->ResolveGenericType(typeA, NULL, NULL);
}
if (typeB->IsUnspecializedTypeVariation())
{
SetAndRestoreValue<BfTypeInstance*> prevCurTypeInst(selfType->mModule->mCurTypeInstance, selfType);
return selfType->mModule->ResolveGenericType(typeB, NULL, NULL);
}
return typeA == typeB;
}