mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Fixed crash with illegal recursive generic definitions
This commit is contained in:
parent
3cdc70c1be
commit
fda6c326c0
1 changed files with 29 additions and 21 deletions
|
@ -3403,6 +3403,7 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
|
|
||||||
for (auto& validateEntry : deferredTypeValidateList)
|
for (auto& validateEntry : deferredTypeValidateList)
|
||||||
{
|
{
|
||||||
|
SetAndRestoreValue<BfTypeReference*> prevAttributeTypeRef(typeState.mCurAttributeTypeRef, validateEntry.mTypeRef);
|
||||||
SetAndRestoreValue<bool> ignoreErrors(mIgnoreErrors, mIgnoreErrors | validateEntry.mIgnoreErrors);
|
SetAndRestoreValue<bool> ignoreErrors(mIgnoreErrors, mIgnoreErrors | validateEntry.mIgnoreErrors);
|
||||||
ValidateGenericConstraints(validateEntry.mTypeRef, validateEntry.mGenericType, false);
|
ValidateGenericConstraints(validateEntry.mTypeRef, validateEntry.mGenericType, false);
|
||||||
}
|
}
|
||||||
|
@ -4332,34 +4333,41 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy
|
||||||
|
|
||||||
if ((mCompiler->mOptions.mAllowHotSwapping) && (typeInstance->mDefineState < BfTypeDefineState_Defined))
|
if ((mCompiler->mOptions.mAllowHotSwapping) && (typeInstance->mDefineState < BfTypeDefineState_Defined))
|
||||||
{
|
{
|
||||||
auto hotTypeVersion = typeInstance->mHotTypeData->mTypeVersions.back();
|
if (typeInstance->mHotTypeData == NULL)
|
||||||
|
|
||||||
if ((typeInstance->mBaseType != NULL) && (typeInstance->mBaseType->mHotTypeData != NULL))
|
|
||||||
{
|
{
|
||||||
hotTypeVersion->mMembers.Add(typeInstance->mBaseType->mHotTypeData->GetLatestVersion());
|
BF_ASSERT(typeInstance->mTypeFailed);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
for (auto& fieldInst : typeInstance->mFieldInstances)
|
|
||||||
{
|
{
|
||||||
auto fieldDef = fieldInst.GetFieldDef();
|
auto hotTypeVersion = typeInstance->mHotTypeData->mTypeVersions.back();
|
||||||
if ((fieldDef == NULL) || (fieldDef->mIsStatic))
|
|
||||||
continue;
|
|
||||||
auto depType = fieldInst.mResolvedType;
|
|
||||||
|
|
||||||
while (depType->IsSizedArray())
|
if ((typeInstance->mBaseType != NULL) && (typeInstance->mBaseType->mHotTypeData != NULL))
|
||||||
depType = ((BfSizedArrayType*)depType)->mElementType;
|
|
||||||
if (depType->IsStruct())
|
|
||||||
{
|
{
|
||||||
PopulateType(depType);
|
hotTypeVersion->mMembers.Add(typeInstance->mBaseType->mHotTypeData->GetLatestVersion());
|
||||||
auto depTypeInst = depType->ToTypeInstance();
|
|
||||||
BF_ASSERT(depTypeInst->mHotTypeData != NULL);
|
|
||||||
if (depTypeInst->mHotTypeData != NULL)
|
|
||||||
hotTypeVersion->mMembers.Add(depTypeInst->mHotTypeData->GetLatestVersion());
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
for (auto member : hotTypeVersion->mMembers)
|
for (auto& fieldInst : typeInstance->mFieldInstances)
|
||||||
member->mRefCount++;
|
{
|
||||||
|
auto fieldDef = fieldInst.GetFieldDef();
|
||||||
|
if ((fieldDef == NULL) || (fieldDef->mIsStatic))
|
||||||
|
continue;
|
||||||
|
auto depType = fieldInst.mResolvedType;
|
||||||
|
|
||||||
|
while (depType->IsSizedArray())
|
||||||
|
depType = ((BfSizedArrayType*)depType)->mElementType;
|
||||||
|
if (depType->IsStruct())
|
||||||
|
{
|
||||||
|
PopulateType(depType);
|
||||||
|
auto depTypeInst = depType->ToTypeInstance();
|
||||||
|
BF_ASSERT(depTypeInst->mHotTypeData != NULL);
|
||||||
|
if (depTypeInst->mHotTypeData != NULL)
|
||||||
|
hotTypeVersion->mMembers.Add(depTypeInst->mHotTypeData->GetLatestVersion());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto member : hotTypeVersion->mMembers)
|
||||||
|
member->mRefCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeInstance->mDefineState < BfTypeDefineState_Defined)
|
if (typeInstance->mDefineState < BfTypeDefineState_Defined)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue