From fa256701c7cc00cec5f07db260473a60f9c882dd Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 28 Nov 2023 06:39:40 -0500 Subject: [PATCH] ceEmitContext null check --- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index e2b95119..db2b6e79 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -2792,9 +2792,18 @@ void BfModule::ExecuteCEOnCompile(CeEmitContext* ceEmitContext, BfTypeInstance* if (useTypeInstance->IsUnspecializedTypeVariation()) useTypeInstance = GetUnspecializedTypeInstance(useTypeInstance); - SetAndRestoreValue prevTypeInstance(ceEmitContext->mType, useTypeInstance); + BfType* prevContextTypeInstance = NULL; + if (ceEmitContext != NULL) + { + prevContextTypeInstance = ceEmitContext->mType; + ceEmitContext->mType = useTypeInstance; + } + methodInstance = GetRawMethodInstanceAtIdx(useTypeInstance, methodDef->mIdx); result = mCompiler->mCeMachine->Call(methodDef->GetRefNode(), this, methodInstance, {}, (CeEvalFlags)(CeEvalFlags_PersistantError | CeEvalFlags_DeferIfNotOnlyError), NULL); + + if (ceEmitContext != NULL) + ceEmitContext->mType = prevContextTypeInstance; } if ((onCompileKind == BfCEOnCompileKind_TypeDone) && (typeInstance->mDefineState > BfTypeDefineState_CETypeInit))