diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 363838d5..074d7021 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -3010,7 +3010,9 @@ bool BfResolvedTypeSet::GenericTypeEquals(BfGenericTypeInstance* lhsGenericType, { if (lhsGenericType->mTypeDef != ctx->mModule->mContext->mCompiler->mNullableTypeDef) return false; - return Equals(lhsGenericType->mTypeGenericArguments[0], rhsNullableTypeRef->mElementType, ctx); + + auto rhsElemType = ctx->mModule->ResolveTypeRef(rhsNullableTypeRef->mElementType, BfPopulateType_Identity); + return lhsGenericType->mTypeGenericArguments[0] == rhsElemType; } } @@ -3038,14 +3040,7 @@ bool BfResolvedTypeSet::GenericTypeEquals(BfGenericTypeInstance* lhsGenericType, } if (auto rhsQualifiedTypeRef = BfNodeDynCastExact(rhs)) - { - /*auto rhsLeftType = ctx->mModule->ResolveTypeRef(rhsQualifiedTypeRef->mLeft, BfPopulateType_Identity); - if (rhsLeftType == NULL) - return false; - auto rhsRightType = ctx->mModule->ResolveInnerType(rhsLeftType, rhsQualifiedTypeRef->mRight); - if (rhsRightType == NULL) - return false;*/ - + { auto rhsRightType = ctx->mModule->ResolveTypeRef(rhs, BfPopulateType_Identity); return rhsRightType == lhsGenericType; } @@ -3076,17 +3071,6 @@ bool BfResolvedTypeSet::GenericTypeEquals(BfGenericTypeInstance* lhsGenericType, } } - /*if (lhsTypeGenericArguments->size() != rhsGenericTypeInstRef->mGenericArguments.size() + genericParamOffset) - { - return false; - } - - for (int i = 0; i < (int) rhsGenericTypeInstRef->mGenericArguments.size(); i++) - { - if (!Equals(lhsGenericType->mTypeGenericArguments[i + genericParamOffset], rhsGenericTypeInstRef->mGenericArguments[i], module)) - return false; - }*/ - if (!GenericTypeEquals(lhsGenericType, lhsTypeGenericArguments, rhs, ctx, genericParamOffset)) return false; @@ -3136,15 +3120,10 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, BfTypeDef* rhs return BfResolvedTypeSet::Equals(lhs, rhsType, ctx); } -bool BfResolvedTypeSet::EqualsNoAlias(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx) +bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx) { //BP_ZONE("BfResolvedTypeSet::Equals"); -// if ((rhs == ctx->mRootTypeRef) && (ctx->mRootTypeDef != NULL) && (ctx->mRootTypeDef->mTypeCode == BfTypeCode_TypeAlias)) -// { -// return lhs == ctx->mResolvedType; -// } - if (ctx->mRootTypeRef != rhs) { if (auto retTypeRef = BfNodeDynCastExact(rhs)) @@ -3163,17 +3142,6 @@ bool BfResolvedTypeSet::EqualsNoAlias(BfType* lhs, BfTypeReference* rhs, LookupC } } - // auto rhsTypeDefTypeRef = BfNodeDynCast(rhs); -// if (rhsTypeDefTypeRef != NULL) -// { -// // mTypeDef not set, need to resolve in module -// if (rhsTypeDefTypeRef->mTypeDef == NULL) -// { -// auto rhsResolvedType = ctx->mModule->ResolveTypeRef(rhsTypeDefTypeRef, BfPopulateType_Identity, BfResolveTypeRefFlag_AllowGenericParamConstValue); -// return Equals(lhs, rhsResolvedType, ctx); -// } -// } - if (auto declTypeRef = BfNodeDynCastExact(rhs)) { BF_ASSERT(ctx->mResolvedType != NULL); @@ -3505,22 +3473,6 @@ bool BfResolvedTypeSet::EqualsNoAlias(BfType* lhs, BfTypeReference* rhs, LookupC return false; } -bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx) -{ - if (EqualsNoAlias(lhs, rhs, ctx)) - return true; - -// if (lhs->IsTypeAlias()) -// { -// auto underylingType = lhs->GetUnderlyingType(); -// BF_ASSERT(underylingType != NULL); -// if (underylingType != NULL) -// return Equals(underylingType, rhs, ctx); -// } - - return false; -} - void BfResolvedTypeSet::RemoveEntry(BfResolvedTypeSet::Entry* entry) { int hashIdx = (entry->mHash & 0x7FFFFFFF) % mHashSize; diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.h b/IDEHelper/Compiler/BfResolvedTypeUtils.h index ca586c07..230702c0 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.h +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.h @@ -2371,8 +2371,7 @@ public: static int Hash(BfType* type, LookupContext* ctx, bool allowRef = false); static int DirectHash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None); static int Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHashFlags flags = BfHashFlag_None); - static bool Equals(BfType* lhs, BfType* rhs, LookupContext* ctx); - static bool EqualsNoAlias(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx); + static bool Equals(BfType* lhs, BfType* rhs, LookupContext* ctx); static bool Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* ctx); static bool Equals(BfType* lhs, BfTypeReference* rhs, BfTypeDef* rhsTypeDef, LookupContext* ctx);