From f4ef2d1fbf82e34e93810088bd5cb72b10bd5415 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 30 Jun 2023 06:47:03 -0400 Subject: [PATCH] mCurTypeInstance NULL check --- IDEHelper/Compiler/BfResolvedTypeUtils.cpp | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 01a2c7f4..b444d180 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -3429,31 +3429,35 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa if (typeDef->mGenericParamDefs.size() != 0) { + BfTypeDef* commonOuterType = NULL; + auto checkTypeInstance = ctx->mModule->mCurTypeInstance; - if (checkTypeInstance->IsBoxed()) - checkTypeInstance = checkTypeInstance->GetUnderlyingType()->ToTypeInstance(); - - auto outerType = ctx->mModule->mSystem->GetOuterTypeNonPartial(typeDef); - - BfTypeDef* commonOuterType; - if (typeRef == ctx->mRootTypeRef) - commonOuterType = FindRootCommonOuterType(outerType, ctx, checkTypeInstance); - else - commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType); - - if ((commonOuterType == NULL) && (outerType != NULL)) + if (checkTypeInstance != NULL) { - auto staticSearch = ctx->mModule->GetStaticSearch(); - if (staticSearch != NULL) + if (checkTypeInstance->IsBoxed()) + checkTypeInstance = checkTypeInstance->GetUnderlyingType()->ToTypeInstance(); + + auto outerType = ctx->mModule->mSystem->GetOuterTypeNonPartial(typeDef); + + if (typeRef == ctx->mRootTypeRef) + commonOuterType = FindRootCommonOuterType(outerType, ctx, checkTypeInstance); + else + commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType); + + if ((commonOuterType == NULL) && (outerType != NULL)) { - for (auto staticTypeInst : staticSearch->mStaticTypes) + auto staticSearch = ctx->mModule->GetStaticSearch(); + if (staticSearch != NULL) { - auto foundOuterType = ctx->mModule->FindCommonOuterType(staticTypeInst->mTypeDef, outerType); - if ((foundOuterType != NULL) && - ((commonOuterType == NULL) || (foundOuterType->mNestDepth > commonOuterType->mNestDepth))) + for (auto staticTypeInst : staticSearch->mStaticTypes) { - commonOuterType = foundOuterType; - checkTypeInstance = staticTypeInst; + auto foundOuterType = ctx->mModule->FindCommonOuterType(staticTypeInst->mTypeDef, outerType); + if ((foundOuterType != NULL) && + ((commonOuterType == NULL) || (foundOuterType->mNestDepth > commonOuterType->mNestDepth))) + { + commonOuterType = foundOuterType; + checkTypeInstance = staticTypeInst; + } } } }