mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
mHadValidateErrors propagation fix
This commit is contained in:
parent
0e79860ba9
commit
81a9478e77
3 changed files with 32 additions and 3 deletions
|
@ -150,6 +150,8 @@ namespace IDETest
|
|||
TestExt<int>.InnerB<int> c;
|
||||
TestExt<int>.InnerC d;
|
||||
TestExt<float>.InnerC e; //FAIL
|
||||
|
||||
List<String?> badArgType; //FAIL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1846,6 +1846,7 @@ public:
|
|||
bool AreConstraintsSubset(BfGenericParamInstance* checkInner, BfGenericParamInstance* checkOuter);
|
||||
bool CheckConstraintState(BfAstNode* refNode);
|
||||
void ValidateGenericParams(BfGenericParamKind genericParamKind, Span<BfGenericParamInstance*> genericParams);
|
||||
void SetGenericValidationError(BfTypeInstance* typeInst);
|
||||
bool ShouldAllowMultipleDefinitions(BfTypeInstance* typeInst, BfTypeDef* firstDeclaringTypeDef, BfTypeDef* secondDeclaringTypeDef);
|
||||
void CheckInjectNewRevision(BfTypeInstance* typeInstance);
|
||||
void InitType(BfType* resolvedTypeRef, BfPopulateType populateType);
|
||||
|
|
|
@ -394,6 +394,26 @@ void BfModule::ValidateGenericParams(BfGenericParamKind genericParamKind, Span<B
|
|||
}
|
||||
}
|
||||
|
||||
void BfModule::SetGenericValidationError(BfTypeInstance* typeInst)
|
||||
{
|
||||
if ((typeInst->mGenericTypeInfo == NULL) || (typeInst->mGenericTypeInfo->mHadValidateErrors))
|
||||
return;
|
||||
typeInst->mGenericTypeInfo->mHadValidateErrors = true;
|
||||
|
||||
for (auto depKV : typeInst->mDependencyMap)
|
||||
{
|
||||
auto depType = depKV.mKey;
|
||||
auto depEntry = depKV.mValue;
|
||||
if ((depEntry.mFlags & BfDependencyMap::DependencyFlag_TypeGenericArg) != 0)
|
||||
{
|
||||
BF_ASSERT(depType->IsGenericTypeInstance());
|
||||
|
||||
// If A<T> had validate errors then consider B<A<T>> to have validate errors
|
||||
SetGenericValidationError(depType->ToTypeInstance());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* genericTypeInst, bool ignoreErrors)
|
||||
{
|
||||
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()) && (mCurTypeInstance->IsGenericTypeInstance()))
|
||||
|
@ -421,7 +441,7 @@ bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* ge
|
|||
mContext->mUnreifiedModule->PopulateType(underlyingType, BfPopulateType_Declaration);
|
||||
bool result = ValidateGenericConstraints(typeRef, underlyingGenericType, ignoreErrors);
|
||||
if (underlyingGenericType->mGenericTypeInfo->mHadValidateErrors)
|
||||
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true;
|
||||
SetGenericValidationError(genericTypeInst);
|
||||
return result;
|
||||
}
|
||||
return true;
|
||||
|
@ -443,7 +463,7 @@ bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* ge
|
|||
auto outerType = GetOuterType(genericTypeInst);
|
||||
mContext->mUnreifiedModule->PopulateType(outerType, BfPopulateType_Declaration);
|
||||
if ((outerType->mGenericTypeInfo != NULL) && (outerType->mGenericTypeInfo->mHadValidateErrors))
|
||||
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true;
|
||||
SetGenericValidationError(genericTypeInst);
|
||||
}
|
||||
|
||||
for (int paramIdx = startGenericParamIdx; paramIdx < (int)genericTypeInst->mGenericTypeInfo->mGenericParams.size(); paramIdx++)
|
||||
|
@ -464,7 +484,7 @@ bool BfModule::ValidateGenericConstraints(BfAstNode* typeRef, BfTypeInstance* ge
|
|||
if ((genericArg == NULL) || (!CheckGenericConstraints(BfGenericParamSource(genericTypeInst), genericArg, typeRef, genericParamInstance, NULL, &error)))
|
||||
{
|
||||
if (!genericTypeInst->IsUnspecializedTypeVariation())
|
||||
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true;
|
||||
SetGenericValidationError(genericTypeInst);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -16051,6 +16071,12 @@ void BfModule::DoTypeToString(StringImpl& str, BfType* resolvedType, BfTypeNameF
|
|||
{
|
||||
BP_ZONE("BfModule::DoTypeToString");
|
||||
|
||||
if (resolvedType == NULL)
|
||||
{
|
||||
str += "NULL";
|
||||
return;
|
||||
}
|
||||
|
||||
if (resolvedType->mContext == NULL)
|
||||
{
|
||||
str += "*UNINITIALIZED TYPE*";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue