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

Deeper binop interface check for generic param

This commit is contained in:
Brian Fiete 2024-09-26 12:33:51 -04:00
parent f8da7eb618
commit bf3dec931a
3 changed files with 44 additions and 0 deletions

View file

@ -69,11 +69,21 @@ BfBaseClassWalker::BfBaseClassWalker(BfType* typeA, BfType* typeB, BfModule* mod
AddConstraints(typeA, module->GetGenericParamInstance((BfGenericParamType*)typeA));
}
if ((typeA != NULL) && (typeA->IsInterface()))
{
AddInterfaces(typeA, typeA->ToTypeInstance());
}
if ((typeB != NULL) && (typeB->IsGenericParam()))
{
mMayBeFromInterface = true;
AddConstraints(typeB, module->GetGenericParamInstance((BfGenericParamType*)typeB));
}
if ((typeB != NULL) && (typeB->IsInterface()))
{
AddInterfaces(typeB, typeB->ToTypeInstance());
}
}
/*BfBaseClassWalker::BfBaseClassWalker(BfTypeInstance* typeA, BfTypeInstance* typeB)
@ -95,6 +105,8 @@ void BfBaseClassWalker::AddConstraints(BfType* srcType, BfGenericParamInstance*
{
auto typeInst = genericParam->mTypeConstraint->ToTypeInstance();
{
if (typeInst->IsInterface())
AddInterfaces(srcType, typeInst->ToTypeInstance());
Entry entry(srcType, typeInst);
if ((typeInst != NULL) && (!mManualList.Contains(entry)))
mManualList.Add(entry);
@ -103,12 +115,24 @@ void BfBaseClassWalker::AddConstraints(BfType* srcType, BfGenericParamInstance*
for (auto typeInst : genericParam->mInterfaceConstraints)
{
if (typeInst->IsInterface())
AddInterfaces(srcType, typeInst->ToTypeInstance());
Entry entry(srcType, typeInst);
if ((typeInst != NULL) && (!mManualList.Contains(entry)))
mManualList.Add(entry);
}
}
void BfBaseClassWalker::AddInterfaces(BfType* srcType, BfTypeInstance* typeInst)
{
for (auto ifaceEntry : typeInst->mInterfaces)
{
Entry entry(srcType, ifaceEntry.mInterfaceType);
if ((typeInst != NULL) && (!mManualList.Contains(entry)))
mManualList.Add(entry);
}
}
BfBaseClassWalker::Entry BfBaseClassWalker::Next()
{
if (!mManualList.IsEmpty())