1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +02:00

Fix for unbound generic type lookups

This commit is contained in:
Brian Fiete 2022-02-22 08:42:41 -08:00
parent c2490278fa
commit e5f280de32
4 changed files with 20 additions and 6 deletions

View file

@ -3146,11 +3146,13 @@ void BfResolvedTypeSet::HashGenericArguments(BfTypeReference* typeRef, LookupCon
{
for (int genericIdx = 0; genericIdx < BF_MAX(genericTypeRef->mGenericArguments.mSize, genericTypeRef->mCommas.mSize + 1); genericIdx++)
{
bool allowUnboundGeneric = ((ctx->mResolveFlags & BfResolveTypeRefFlag_AllowUnboundGeneric) != 0) && (typeRef == ctx->mRootTypeRef);
BfAstNode* genericArgTypeRef = NULL;
if (genericIdx < genericTypeRef->mGenericArguments.mSize)
genericArgTypeRef = genericTypeRef->mGenericArguments[genericIdx];
if ((ctx->mResolveFlags & BfResolveTypeRefFlag_AllowUnboundGeneric) != 0)
if (allowUnboundGeneric)
{
if (BfNodeIsExact<BfWildcardTypeReference>(genericArgTypeRef))
genericArgTypeRef = NULL;
@ -3160,14 +3162,15 @@ void BfResolvedTypeSet::HashGenericArguments(BfTypeReference* typeRef, LookupCon
if (genericArgTypeRef != NULL)
{
argHashVal = Hash(genericArgTypeRef, ctx, BfHashFlag_AllowGenericParamConstValue, hashSeed + 1);
if ((ctx->mResolveFlags & BfResolveTypeRefFlag_ForceUnboundGeneric) != 0)
if ((allowUnboundGeneric) && ((ctx->mResolveFlags & BfResolveTypeRefFlag_ForceUnboundGeneric) != 0))
genericArgTypeRef = NULL;
}
if (genericArgTypeRef == NULL)
{
if ((ctx->mResolveFlags & BfResolveTypeRefFlag_AllowUnboundGeneric) != 0)
{
if (allowUnboundGeneric)
{
ctx->mIsUnboundGeneric = true;
argHashVal = (((int)BfGenericParamKind_Type + 0xB00) << 8) ^ (genericIdx + 1);
argHashVal = HASH_MIX(argHashVal, hashSeed + 1);
}