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++;
|
mCurMethodState->mLocals[compositeVariableIdx]->mCompositeCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckVariableDef(paramVar);
|
if (!mCurTypeInstance->IsDelegateOrFunction())
|
||||||
|
CheckVariableDef(paramVar);
|
||||||
paramVar->Init();
|
paramVar->Init();
|
||||||
AddLocalVariableDef(paramVar);
|
AddLocalVariableDef(paramVar);
|
||||||
if (!isParamSkipped)
|
if (!isParamSkipped)
|
||||||
|
|
|
@ -7674,8 +7674,16 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
}
|
}
|
||||||
if ((genericParam->mGenericParamKind == BfGenericParamKind_Method) && (methodGenericArguments != NULL))
|
if ((genericParam->mGenericParamKind == BfGenericParamKind_Method) && (methodGenericArguments != NULL))
|
||||||
{
|
{
|
||||||
if (genericParam->mGenericParamIdx < (int)methodGenericArguments->size())
|
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);
|
BF_ASSERT(allowFail);
|
||||||
}
|
}
|
||||||
return unspecializedType;
|
return unspecializedType;
|
||||||
|
@ -7785,7 +7793,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
if (newGenericArg->IsVar())
|
if (newGenericArg->IsVar())
|
||||||
return newGenericArg;
|
return newGenericArg;
|
||||||
|
|
||||||
if (newGenericArg->IsGenericParam())
|
if (newGenericArg->IsTypeGenericParam())
|
||||||
wantGeneric = true;
|
wantGeneric = true;
|
||||||
if (newGenericArg->IsUnspecializedType())
|
if (newGenericArg->IsUnspecializedType())
|
||||||
isUnspecialized = true;
|
isUnspecialized = true;
|
||||||
|
@ -7804,6 +7812,9 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
if (unspecializedGenericTupleType == NULL)
|
if (unspecializedGenericTupleType == NULL)
|
||||||
wantGeneric = false;
|
wantGeneric = false;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
wantGeneric = false;
|
||||||
|
|
||||||
auto baseType = (BfTypeInstance*)ResolveTypeDef(mContext->mCompiler->mValueTypeTypeDef);
|
auto baseType = (BfTypeInstance*)ResolveTypeDef(mContext->mCompiler->mValueTypeTypeDef);
|
||||||
|
|
||||||
BfTypeInstance* tupleType = NULL;
|
BfTypeInstance* tupleType = NULL;
|
||||||
|
@ -7909,7 +7920,7 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
bool isUnspecialized = false;
|
bool isUnspecialized = false;
|
||||||
auto _CheckType = [&](BfType* type)
|
auto _CheckType = [&](BfType* type)
|
||||||
{
|
{
|
||||||
if (type->IsGenericParam())
|
if (type->IsTypeGenericParam())
|
||||||
wantGeneric = true;
|
wantGeneric = true;
|
||||||
if (type->IsUnspecializedType())
|
if (type->IsUnspecializedType())
|
||||||
isUnspecialized = true;
|
isUnspecialized = true;
|
||||||
|
@ -7943,6 +7954,9 @@ BfType* BfModule::ResolveGenericType(BfType* unspecializedType, BfTypeVector* ty
|
||||||
if (unspecializedGenericDelegateType == NULL)
|
if (unspecializedGenericDelegateType == NULL)
|
||||||
wantGeneric = false;
|
wantGeneric = false;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
wantGeneric = false;
|
||||||
|
|
||||||
BfTypeInstance* delegateType = NULL;
|
BfTypeInstance* delegateType = NULL;
|
||||||
auto baseDelegateType = ResolveTypeDef(mCompiler->mDelegateTypeDef)->ToTypeInstance();
|
auto baseDelegateType = ResolveTypeDef(mCompiler->mDelegateTypeDef)->ToTypeInstance();
|
||||||
|
|
||||||
|
@ -10605,7 +10619,7 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
else
|
else
|
||||||
fieldName = StrFormat("%d", fieldIdx);
|
fieldName = StrFormat("%d", fieldIdx);
|
||||||
|
|
||||||
if (type->IsGenericParam())
|
if (type->IsTypeGenericParam())
|
||||||
wantGeneric = true;
|
wantGeneric = true;
|
||||||
if (type->IsUnspecializedType())
|
if (type->IsUnspecializedType())
|
||||||
isUnspecialized = true;
|
isUnspecialized = true;
|
||||||
|
@ -10621,6 +10635,9 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
if ((mCurTypeInstance == NULL) || (!mCurTypeInstance->IsGenericTypeInstance()))
|
if ((mCurTypeInstance == NULL) || (!mCurTypeInstance->IsGenericTypeInstance()))
|
||||||
wantGeneric = false;
|
wantGeneric = false;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
wantGeneric = false;
|
||||||
|
|
||||||
auto baseType = (BfTypeInstance*)ResolveTypeDef(mContext->mCompiler->mValueTypeTypeDef, BfPopulateType_Identity);
|
auto baseType = (BfTypeInstance*)ResolveTypeDef(mContext->mCompiler->mValueTypeTypeDef, BfPopulateType_Identity);
|
||||||
BfTypeInstance* tupleType = NULL;
|
BfTypeInstance* tupleType = NULL;
|
||||||
if (wantGeneric)
|
if (wantGeneric)
|
||||||
|
@ -10776,8 +10793,8 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
bool isUnspecialized = false;
|
bool isUnspecialized = false;
|
||||||
auto _CheckType = [&](BfType* type)
|
auto _CheckType = [&](BfType* type)
|
||||||
{
|
{
|
||||||
if (type->IsGenericParam())
|
if (type->IsTypeGenericParam())
|
||||||
wantGeneric = true;
|
wantGeneric = true;
|
||||||
if (type->IsUnspecializedType())
|
if (type->IsUnspecializedType())
|
||||||
isUnspecialized = true;
|
isUnspecialized = true;
|
||||||
};
|
};
|
||||||
|
@ -10857,6 +10874,9 @@ BfType* BfModule::ResolveTypeRef(BfTypeReference* typeRef, BfPopulateType popula
|
||||||
if ((mCurTypeInstance == NULL) || (!mCurTypeInstance->IsGenericTypeInstance()))
|
if ((mCurTypeInstance == NULL) || (!mCurTypeInstance->IsGenericTypeInstance()))
|
||||||
wantGeneric = false;
|
wantGeneric = false;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
wantGeneric = false;
|
||||||
|
|
||||||
BfTypeInstance* baseDelegateType = NULL;
|
BfTypeInstance* baseDelegateType = NULL;
|
||||||
if (mCompiler->mDelegateTypeDef != NULL)
|
if (mCompiler->mDelegateTypeDef != NULL)
|
||||||
baseDelegateType = ResolveTypeDef(mCompiler->mDelegateTypeDef)->ToTypeInstance();
|
baseDelegateType = ResolveTypeDef(mCompiler->mDelegateTypeDef)->ToTypeInstance();
|
||||||
|
|
|
@ -4088,6 +4088,8 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
|
||||||
if (rhsDelegateType == NULL)
|
if (rhsDelegateType == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
bool wantGeneric = false;
|
||||||
|
|
||||||
BfDelegateInfo* lhsDelegateInfo = lhs->GetDelegateInfo();
|
BfDelegateInfo* lhsDelegateInfo = lhs->GetDelegateInfo();
|
||||||
|
|
||||||
auto lhsTypeInstance = lhs->ToTypeInstance();
|
auto lhsTypeInstance = lhs->ToTypeInstance();
|
||||||
|
@ -4098,6 +4100,12 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
|
||||||
|
|
||||||
if ((lhs->IsDelegate()) != rhsIsDelegate)
|
if ((lhs->IsDelegate()) != rhsIsDelegate)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
auto _CheckType = [&](BfType* type)
|
||||||
|
{
|
||||||
|
if (type->IsTypeGenericParam())
|
||||||
|
wantGeneric = true;
|
||||||
|
};
|
||||||
|
|
||||||
BfCallingConvention rhsCallingConvention = BfCallingConvention_Unspecified;
|
BfCallingConvention rhsCallingConvention = BfCallingConvention_Unspecified;
|
||||||
if (ctx->mRootTypeRef == rhsDelegateType)
|
if (ctx->mRootTypeRef == rhsDelegateType)
|
||||||
|
@ -4105,9 +4113,10 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
|
||||||
else
|
else
|
||||||
ctx->mModule->GetDelegateTypeRefAttributes(rhsDelegateType, rhsCallingConvention);
|
ctx->mModule->GetDelegateTypeRefAttributes(rhsDelegateType, rhsCallingConvention);
|
||||||
if (lhsDelegateInfo->mCallingConvention != rhsCallingConvention)
|
if (lhsDelegateInfo->mCallingConvention != rhsCallingConvention)
|
||||||
return false;
|
return false;
|
||||||
if (!Equals(lhsDelegateInfo->mReturnType, rhsDelegateType->mReturnType, ctx))
|
if (!Equals(lhsDelegateInfo->mReturnType, rhsDelegateType->mReturnType, ctx))
|
||||||
return false;
|
return false;
|
||||||
|
_CheckType(lhsDelegateInfo->mReturnType);
|
||||||
|
|
||||||
bool isMutating = true;
|
bool isMutating = true;
|
||||||
|
|
||||||
|
@ -4155,12 +4164,23 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext*
|
||||||
auto paramTypeRef = rhsDelegateType->mParams[paramIdx]->mTypeRef;
|
auto paramTypeRef = rhsDelegateType->mParams[paramIdx]->mTypeRef;
|
||||||
if (!Equals(lhsDelegateInfo->mParams[paramIdx], paramTypeRef, ctx))
|
if (!Equals(lhsDelegateInfo->mParams[paramIdx], paramTypeRef, ctx))
|
||||||
return false;
|
return false;
|
||||||
|
_CheckType(lhsDelegateInfo->mParams[paramIdx]);
|
||||||
StringView rhsParamName;
|
StringView rhsParamName;
|
||||||
if (rhsDelegateType->mParams[paramIdx]->mNameNode != NULL)
|
if (rhsDelegateType->mParams[paramIdx]->mNameNode != NULL)
|
||||||
rhsParamName = rhsDelegateType->mParams[paramIdx]->mNameNode->ToStringView();
|
rhsParamName = rhsDelegateType->mParams[paramIdx]->mNameNode->ToStringView();
|
||||||
if (invokeMethodDef->mParams[paramIdx]->mName != rhsParamName)
|
if (invokeMethodDef->mParams[paramIdx]->mName != rhsParamName)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((ctx->mModule->mCurTypeInstance == NULL) || (!ctx->mModule->mCurTypeInstance->IsGenericTypeInstance()))
|
||||||
|
wantGeneric = false;
|
||||||
|
|
||||||
|
//TODO:
|
||||||
|
wantGeneric = false;
|
||||||
|
|
||||||
|
if (wantGeneric != lhsTypeInstance->IsGenericTypeInstance())
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (lhs->IsTypeInstance())
|
else if (lhs->IsTypeInstance())
|
||||||
|
|
|
@ -587,6 +587,8 @@ public:
|
||||||
virtual bool IsIn() { return false; }
|
virtual bool IsIn() { return false; }
|
||||||
virtual bool IsOut() { return false; }
|
virtual bool IsOut() { return false; }
|
||||||
virtual bool IsGenericParam() { return false; }
|
virtual bool IsGenericParam() { return false; }
|
||||||
|
virtual bool IsTypeGenericParam() { return false; }
|
||||||
|
virtual bool IsMethodGenericParam() { return false; }
|
||||||
virtual bool IsClosure() { return false; }
|
virtual bool IsClosure() { return false; }
|
||||||
virtual bool IsMethodRef() { return false; }
|
virtual bool IsMethodRef() { return false; }
|
||||||
virtual bool IsTuple() { return false; }
|
virtual bool IsTuple() { return false; }
|
||||||
|
@ -1073,6 +1075,8 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsGenericParam() override { return true; }
|
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 IsUnspecializedType() override { return true; }
|
||||||
virtual bool IsReified() override { return false; }
|
virtual bool IsReified() override { return false; }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue