1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fixed stack overflow with inner type as base type

This commit is contained in:
Brian Fiete 2020-09-25 05:38:35 -07:00
parent 980fc63b74
commit 797aa7cedc
2 changed files with 27 additions and 8 deletions

View file

@ -2227,6 +2227,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
SizedArray<BfInterfaceDecl, 8> interfaces; SizedArray<BfInterfaceDecl, 8> interfaces;
HashSet<BfTypeInstance*> ifaceSet; HashSet<BfTypeInstance*> ifaceSet;
typeInstance->mRebuildFlags = (BfTypeRebuildFlags)(typeInstance->mRebuildFlags | BfTypeRebuildFlag_ResolvingBase);
if (resolvedTypeRef == mContext->mBfObjectType) if (resolvedTypeRef == mContext->mBfObjectType)
{ {
baseType = NULL; baseType = NULL;
@ -2326,7 +2328,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
if (checkType->IsPrimitiveType()) if (checkType->IsPrimitiveType())
Fail(StrFormat("Enum '%s' cannot be specified as '%s' because it has a payload", Fail(StrFormat("Enum '%s' cannot be specified as '%s' because it has a payload",
TypeToString(typeInstance).c_str(), TypeToString(checkType).c_str()), TypeToString(typeInstance).c_str(), TypeToString(checkType).c_str()),
checkTypeRef); checkTypeRef, true);
else else
Fail("Enums cannot derive from other types", checkTypeRef); Fail("Enums cannot derive from other types", checkTypeRef);
continue; continue;
@ -2376,11 +2378,25 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
baseTypeRef = checkTypeRef; baseTypeRef = checkTypeRef;
if (checkTypeInst != NULL) if (checkTypeInst != NULL)
{ {
baseType = checkTypeInst; auto checkOuter = checkTypeInst;
/*if ((resolvedTypeRef->IsBoxed()) && (baseType->IsValueType())) while (checkOuter != NULL)
{ {
baseType = CreateBoxedType(baseType); if (checkOuter == typeInstance)
}*/ {
Fail(StrFormat("Type '%s' cannot be declare inner type '%s' as a base type",
TypeToString(typeInstance).c_str(),
TypeToString(checkTypeInst).c_str()), checkTypeRef, true);
checkTypeInst = NULL;
break;
}
checkOuter = GetOuterType(checkOuter);
}
}
if (checkTypeInst != NULL)
{
baseType = checkTypeInst;
} }
} }
} }
@ -2434,11 +2450,11 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
if (!typeInstance->IsBoxed()) if (!typeInstance->IsBoxed())
{ {
BfType* outerType = GetOuterType(typeInstance); BfType* outerType = GetOuterType(typeInstance);
if (outerType != NULL) if (outerType != NULL)
{ {
PopulateType(outerType, BfPopulateType_BaseType); PopulateType(outerType, BfPopulateType_Identity);
AddDependency(outerType, typeInstance, BfDependencyMap::DependencyFlag_OuterType); AddDependency(outerType, typeInstance, BfDependencyMap::DependencyFlag_OuterType);
} }
} }
@ -2509,6 +2525,8 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
} }
} }
typeInstance->mRebuildFlags = (BfTypeRebuildFlags)(typeInstance->mRebuildFlags & ~BfTypeRebuildFlag_ResolvingBase);
if (populateType <= BfPopulateType_BaseType) if (populateType <= BfPopulateType_BaseType)
return; return;

View file

@ -397,7 +397,8 @@ enum BfTypeRebuildFlags
BfTypeRebuildFlag_SpecializedByAutocompleteMethod = 0x200, BfTypeRebuildFlag_SpecializedByAutocompleteMethod = 0x200,
BfTypeRebuildFlag_UnderlyingTypeDeferred = 0x400, BfTypeRebuildFlag_UnderlyingTypeDeferred = 0x400,
BfTypeRebuildFlag_TypeDataSaved = 0x800, BfTypeRebuildFlag_TypeDataSaved = 0x800,
BfTypeRebuildFlag_InTempPool = 0x1000 BfTypeRebuildFlag_InTempPool = 0x1000,
BfTypeRebuildFlag_ResolvingBase = 0x2000
}; };
class BfTypeDIReplaceCallback; class BfTypeDIReplaceCallback;