From 2f6484894efa073b461973a031b47435801de1bd Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 26 Aug 2022 07:08:57 -0700 Subject: [PATCH] Fixed HotTypeVersion base type dependency --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 51 +++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 583465c0..39facad4 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -4489,42 +4489,45 @@ void BfModule::DoPopulateType(BfType* resolvedTypeRef, BfPopulateType populateTy return; } - if ((mCompiler->mOptions.mAllowHotSwapping) && - (typeInstance->mDefineState < BfTypeDefineState_HasInterfaces_Direct) && - (typeInstance->mDefineState != BfTypeDefineState_ResolvingBaseType)) + if (mCompiler->mOptions.mAllowHotSwapping) { - if (typeInstance->mHotTypeData == NULL) + if (typeInstance->mDefineState < BfTypeDefineState_HasInterfaces_Direct) { - typeInstance->mHotTypeData = new BfHotTypeData(); - BfLogSysM("Created HotTypeData %p created for type %p in DoPopulateType\n", typeInstance->mHotTypeData, typeInstance); + if (typeInstance->mHotTypeData == NULL) + { + typeInstance->mHotTypeData = new BfHotTypeData(); + BfLogSysM("Created HotTypeData %p created for type %p in DoPopulateType\n", typeInstance->mHotTypeData, typeInstance); + } + + // Clear any unused versions (if we have errors, etc) + if (mCompiler->mHotState != NULL) + typeInstance->mHotTypeData->ClearVersionsAfter(mCompiler->mHotState->mCommittedHotCompileIdx); + else + BF_ASSERT(typeInstance->mHotTypeData->mTypeVersions.IsEmpty()); // We should have created a new HotTypeData when rebuilding the type + + BfHotTypeVersion* hotTypeVersion = new BfHotTypeVersion(); + hotTypeVersion->mTypeId = typeInstance->mTypeId; + hotTypeVersion->mDeclHotCompileIdx = mCompiler->mOptions.mHotCompileIdx; + if (mCompiler->IsHotCompile()) + hotTypeVersion->mCommittedHotCompileIdx = -1; + else + hotTypeVersion->mCommittedHotCompileIdx = 0; + hotTypeVersion->mRefCount++; + typeInstance->mHotTypeData->mTypeVersions.Add(hotTypeVersion); + + BfLogSysM("BfHotTypeVersion %p created for type %p\n", hotTypeVersion, typeInstance); } - // Clear any unused versions (if we have errors, etc) - if (mCompiler->mHotState != NULL) - typeInstance->mHotTypeData->ClearVersionsAfter(mCompiler->mHotState->mCommittedHotCompileIdx); - else - BF_ASSERT(typeInstance->mHotTypeData->mTypeVersions.IsEmpty()); // We should have created a new HotTypeData when rebuilding the type - - BfHotTypeVersion* hotTypeVersion = new BfHotTypeVersion(); - hotTypeVersion->mTypeId = typeInstance->mTypeId; + auto hotTypeVersion = typeInstance->mHotTypeData->mTypeVersions.back(); if (typeInstance->mBaseType != NULL) { if (typeInstance->mBaseType->mHotTypeData != NULL) hotTypeVersion->mBaseType = typeInstance->mBaseType->mHotTypeData->GetLatestVersion(); - else + else if (populateType >= BfPopulateType_Interfaces_All) { AssertErrorState(); } } - hotTypeVersion->mDeclHotCompileIdx = mCompiler->mOptions.mHotCompileIdx; - if (mCompiler->IsHotCompile()) - hotTypeVersion->mCommittedHotCompileIdx = -1; - else - hotTypeVersion->mCommittedHotCompileIdx = 0; - hotTypeVersion->mRefCount++; - typeInstance->mHotTypeData->mTypeVersions.Add(hotTypeVersion); - - BfLogSysM("BfHotTypeVersion %p created for type %p\n", hotTypeVersion, typeInstance); } BF_ASSERT(!typeInstance->mNeedsMethodProcessing);