1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-16 07:14:09 +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(); return typeRef->ToString();
} }
bool BfTypeUtils::TypeEquals(BfType* typeA, BfType* typeB, BfType* selfType) bool BfTypeUtils::TypeEquals(BfType* typeA, BfType* typeB, BfTypeInstance* selfType)
{ {
if (typeA->IsSelf()) if (typeA->IsUnspecializedTypeVariation())
typeA = selfType; {
if (typeB->IsSelf()) SetAndRestoreValue<BfTypeInstance*> prevCurTypeInst(selfType->mModule->mCurTypeInstance, selfType);
typeB = 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; return typeA == typeB;
} }