1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 19:48:20 +02:00

Fixed nullable lookup issue with type aliases

This commit is contained in:
Brian Fiete 2020-05-31 09:34:28 -07:00
parent 8bdfb8e93e
commit f9ee4010cb
2 changed files with 6 additions and 55 deletions

View file

@ -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<BfQualifiedTypeReference>(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<BfModifiedTypeRef>(rhs))
@ -3163,17 +3142,6 @@ bool BfResolvedTypeSet::EqualsNoAlias(BfType* lhs, BfTypeReference* rhs, LookupC
}
}
// auto rhsTypeDefTypeRef = BfNodeDynCast<BfTypeDefTypeReference>(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<BfDeclTypeRef>(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;