1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

In 'for' loop, check base types for enumerator interfaces

This commit is contained in:
Brian Fiete 2022-06-27 15:39:50 -07:00
parent 1fe4a27abf
commit 84bc0ad1de

View file

@ -6343,6 +6343,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
if (targetTypeInstance != NULL) if (targetTypeInstance != NULL)
{ {
PopulateType(targetTypeInstance, BfPopulateType_DataAndMethods); PopulateType(targetTypeInstance, BfPopulateType_DataAndMethods);
auto getEnumeratorMethod = GetMethodByName(targetTypeInstance, "GetEnumerator", 0, true); auto getEnumeratorMethod = GetMethodByName(targetTypeInstance, "GetEnumerator", 0, true);
if (!getEnumeratorMethod) if (!getEnumeratorMethod)
{ {
@ -6410,9 +6411,10 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
}; };
auto enumeratorTypeInst = itr.mType->ToTypeInstance(); auto enumeratorTypeInst = itr.mType->ToTypeInstance();
while (enumeratorTypeInst != NULL)
if (enumeratorTypeInst != NULL)
{ {
PopulateType(enumeratorTypeInst, Beefy::BfPopulateType_Interfaces_All);
for (auto& interfaceRef : enumeratorTypeInst->mInterfaces) for (auto& interfaceRef : enumeratorTypeInst->mInterfaces)
{ {
BfTypeInstance* interface = interfaceRef.mInterfaceType; BfTypeInstance* interface = interfaceRef.mInterfaceType;
@ -6432,7 +6434,10 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
varType = CreateRefType(varType); varType = CreateRefType(varType);
} }
} }
break;
} }
enumeratorTypeInst = enumeratorTypeInst->mBaseType;
} }
if ((genericItrInterface == NULL) && (genericParamInst != NULL)) if ((genericItrInterface == NULL) && (genericParamInst != NULL))