1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-10 04:22:20 +02:00

mCurTypeInstance NULL check

This commit is contained in:
Brian Fiete 2023-06-30 06:47:03 -04:00
parent c18c76b4fe
commit f4ef2d1fbf

View file

@ -3429,31 +3429,35 @@ int BfResolvedTypeSet::DoHash(BfTypeReference* typeRef, LookupContext* ctx, BfHa
if (typeDef->mGenericParamDefs.size() != 0) if (typeDef->mGenericParamDefs.size() != 0)
{ {
BfTypeDef* commonOuterType = NULL;
auto checkTypeInstance = ctx->mModule->mCurTypeInstance; auto checkTypeInstance = ctx->mModule->mCurTypeInstance;
if (checkTypeInstance->IsBoxed()) if (checkTypeInstance != NULL)
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))
{ {
auto staticSearch = ctx->mModule->GetStaticSearch(); if (checkTypeInstance->IsBoxed())
if (staticSearch != NULL) 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); for (auto staticTypeInst : staticSearch->mStaticTypes)
if ((foundOuterType != NULL) &&
((commonOuterType == NULL) || (foundOuterType->mNestDepth > commonOuterType->mNestDepth)))
{ {
commonOuterType = foundOuterType; auto foundOuterType = ctx->mModule->FindCommonOuterType(staticTypeInst->mTypeDef, outerType);
checkTypeInstance = staticTypeInst; if ((foundOuterType != NULL) &&
((commonOuterType == NULL) || (foundOuterType->mNestDepth > commonOuterType->mNestDepth)))
{
commonOuterType = foundOuterType;
checkTypeInstance = staticTypeInst;
}
} }
} }
} }