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:
parent
156585773d
commit
ef6b52a0ac
4 changed files with 54 additions and 9 deletions
|
@ -17990,7 +17990,8 @@ void BfModule::ProcessMethod_SetupParams(BfMethodInstance* methodInstance, BfTyp
|
|||
mCurMethodState->mLocals[compositeVariableIdx]->mCompositeCount++;
|
||||
}
|
||||
|
||||
CheckVariableDef(paramVar);
|
||||
if (!mCurTypeInstance->IsDelegateOrFunction())
|
||||
CheckVariableDef(paramVar);
|
||||
paramVar->Init();
|
||||
AddLocalVariableDef(paramVar);
|
||||
if (!isParamSkipped)
|
||||
|
|
|
@ -7674,8 +7674,16 @@ 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]);
|
||||
if (genericParam->mGenericParamIdx < (int)methodGenericArguments->size())
|
||||
{
|
||||
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,8 +10793,8 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
|||
bool isUnspecialized = false;
|
||||
auto _CheckType = [&](BfType* type)
|
||||
{
|
||||
if (type->IsGenericParam())
|
||||
wantGeneric = true;
|
||||
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();
|
||||
|
|
|
@ -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();
|
||||
|
@ -4098,6 +4100,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)
|
||||
|
@ -4105,9 +4113,10 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
|
|||
else
|
||||
ctx->mModule->GetDelegateTypeRefAttributes(rhsDelegateType, rhsCallingConvention);
|
||||
if (lhsDelegateInfo->mCallingConvention != rhsCallingConvention)
|
||||
return false;
|
||||
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())
|
||||
|
|
|
@ -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; }
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue