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

Experimental disabling of 'wantGeneric=false' for inner delegates/tuples

This commit is contained in:
Brian Fiete 2022-01-01 06:36:48 -05:00
parent 156585773d
commit ef6b52a0ac
4 changed files with 54 additions and 9 deletions

View file

@ -17990,6 +17990,7 @@ void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfTyp
mCurMethodState->mLocals[compositeVariableIdx]->mCompositeCount++;
}
if (!mCurTypeInstance->IsDelegateOrFunction())
CheckVariableDef(paramVar);
paramVar->Init();
AddLocalVariableDef(paramVar);

View file

@ -7675,7 +7675,15 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
if ((genericParam->mGenericParamKind == BfGenericParamKind_Method) && (methodGenericArguments != NULL))
{
if (genericParam->mGenericParamIdx < (int)methodGenericArguments->size())
return FixIntUnknown((*methodGenericArguments)[genericParam->mGenericParamIdx]);
{
auto resolvedType = FixIntUnknown((*methodGenericArguments)[genericParam->mGenericParamIdx]);
if ((resolvedType != NULL) && (resolvedType->IsGenericParam()))
{
auto genericParamType = (BfGenericParamType*)resolvedType;
//BF_ASSERT(genericParamType->mGenericParamKind != BfGenericParamKind_Method);
}
return resolvedType;
}
BF_ASSERT(allowFail);
}
return unspecializedType;
@ -7785,7 +7793,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
if (newGenericArg->IsVar())
return newGenericArg;
if (newGenericArg->IsGenericParam())
if (newGenericArg->IsTypeGenericParam())
wantGeneric = true;
if (newGenericArg->IsUnspecializedType())
isUnspecialized = true;
@ -7804,6 +7812,9 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
if (unspecializedGenericTupleType == NULL)
wantGeneric = false;
//TODO:
wantGeneric = false;
auto baseType = (BfTypeInstance*)ResolveTypeDef(mContext->mCompiler->mValueTypeTypeDef);
BfTypeInstance* tupleType = NULL;
@ -7909,7 +7920,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
bool isUnspecialized = false;
auto _CheckType = [&](BfType* type)
{
if (type->IsGenericParam())
if (type->IsTypeGenericParam())
wantGeneric = true;
if (type->IsUnspecializedType())
isUnspecialized = true;
@ -7943,6 +7954,9 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
if (unspecializedGenericDelegateType == NULL)
wantGeneric = false;
//TODO:
wantGeneric = false;
BfTypeInstance* delegateType = NULL;
auto baseDelegateType = ResolveTypeDef(mCompiler->mDelegateTypeDef)->ToTypeInstance();
@ -10605,7 +10619,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
else
fieldName = StrFormat("%d", fieldIdx);
if (type->IsGenericParam())
if (type->IsTypeGenericParam())
wantGeneric = true;
if (type->IsUnspecializedType())
isUnspecialized = true;
@ -10621,6 +10635,9 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
if ((mCurTypeInstance == NULL) || (!mCurTypeInstance->IsGenericTypeInstance()))
wantGeneric = false;
//TODO:
wantGeneric = false;
auto baseType = (BfTypeInstance*)ResolveTypeDef(mContext->mCompiler->mValueTypeTypeDef, BfPopulateType_Identity);
BfTypeInstance* tupleType = NULL;
if (wantGeneric)
@ -10776,7 +10793,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
bool isUnspecialized = false;
auto _CheckType = [&](BfType* type)
{
if (type->IsGenericParam())
if (type->IsTypeGenericParam())
wantGeneric = true;
if (type->IsUnspecializedType())
isUnspecialized = true;
@ -10857,6 +10874,9 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
if ((mCurTypeInstance == NULL) || (!mCurTypeInstance->IsGenericTypeInstance()))
wantGeneric = false;
//TODO:
wantGeneric = false;
BfTypeInstance* baseDelegateType = NULL;
if (mCompiler->mDelegateTypeDef != NULL)
baseDelegateType = ResolveTypeDef(mCompiler->mDelegateTypeDef)->ToTypeInstance();

View file

@ -4088,6 +4088,8 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
if (rhsDelegateType == NULL)
return false;
bool wantGeneric = false;
BfDelegateInfo* lhsDelegateInfo = lhs->GetDelegateInfo();
auto lhsTypeInstance = lhs->ToTypeInstance();
@ -4099,6 +4101,12 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
if ((lhs->IsDelegate()) != rhsIsDelegate)
return false;
auto _CheckType = [&](BfType* type)
{
if (type->IsTypeGenericParam())
wantGeneric = true;
};
BfCallingConvention rhsCallingConvention = BfCallingConvention_Unspecified;
if (ctx->mRootTypeRef == rhsDelegateType)
rhsCallingConvention = ctx->mCallingConvention;
@ -4108,6 +4116,7 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
return false;
if (!Equals(lhsDelegateInfo->mReturnType, rhsDelegateType->mReturnType, ctx))
return false;
_CheckType(lhsDelegateInfo->mReturnType);
bool isMutating = true;
@ -4155,12 +4164,23 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
auto paramTypeRef = rhsDelegateType->mParams[paramIdx]->mTypeRef;
if (!Equals(lhsDelegateInfo->mParams[paramIdx], paramTypeRef, ctx))
return false;
_CheckType(lhsDelegateInfo->mParams[paramIdx]);
StringView rhsParamName;
if (rhsDelegateType->mParams[paramIdx]->mNameNode != NULL)
rhsParamName = rhsDelegateType->mParams[paramIdx]->mNameNode->ToStringView();
if (invokeMethodDef->mParams[paramIdx]->mName != rhsParamName)
return false;
}
if ((ctx->mModule->mCurTypeInstance == NULL) || (!ctx->mModule->mCurTypeInstance->IsGenericTypeInstance()))
wantGeneric = false;
//TODO:
wantGeneric = false;
if (wantGeneric != lhsTypeInstance->IsGenericTypeInstance())
return false;
return true;
}
else if (lhs->IsTypeInstance())

View file

@ -587,6 +587,8 @@ public:
virtual bool IsIn() { return false; }
virtual bool IsOut() { return false; }
virtual bool IsGenericParam() { return false; }
virtual bool IsTypeGenericParam() { return false; }
virtual bool IsMethodGenericParam() { return false; }
virtual bool IsClosure() { return false; }
virtual bool IsMethodRef() { return false; }
virtual bool IsTuple() { return false; }
@ -1073,6 +1075,8 @@ public:
public:
bool IsGenericParam() override { return true; }
bool IsTypeGenericParam() override { return mGenericParamKind == BfGenericParamKind_Type; }
bool IsMethodGenericParam() override { return mGenericParamKind == BfGenericParamKind_Type; }
virtual bool IsUnspecializedType() override { return true; }
virtual bool IsReified() override { return false; }
};