Przeglądaj źródła

mCurTypeInstance NULL check

Brian Fiete 2 lat temu
rodzic
commit
f4ef2d1fbf
1 zmienionych plików z 22 dodań i 18 usunięć
  1. 22 18
      IDEHelper/Compiler/BfResolvedTypeUtils.cpp

+ 22 - 18
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();
+			if (checkTypeInstance != NULL)
+			{
+				if (checkTypeInstance->IsBoxed())
+					checkTypeInstance = checkTypeInstance->GetUnderlyingType()->ToTypeInstance();
 
-			auto outerType = ctx->mModule->mSystem->GetOuterTypeNonPartial(typeDef);
+				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 (typeRef == ctx->mRootTypeRef)
+					commonOuterType = FindRootCommonOuterType(outerType, ctx, checkTypeInstance);
+				else
+					commonOuterType = ctx->mModule->FindCommonOuterType(ctx->mModule->mCurTypeInstance->mTypeDef, outerType);
 
-			if ((commonOuterType == NULL) && (outerType != NULL))
-			{
-				auto staticSearch = ctx->mModule->GetStaticSearch();
-				if (staticSearch != NULL)
+				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;
+							}
 						}
 					}
 				}