mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 04:22:20 +02:00
Improved errors of invalid typealias generics
This commit is contained in:
parent
5c88091760
commit
74098aa9eb
1 changed files with 9 additions and 5 deletions
|
@ -306,7 +306,7 @@ bool BfModule::FinishGenericParams(BfType* resolvedTypeRef)
|
|||
|
||||
bool BfModule::ValidateGenericConstraints(BfTypeReference* typeRef, BfTypeInstance* genericTypeInst, bool ignoreErrors)
|
||||
{
|
||||
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()))
|
||||
if ((mCurTypeInstance != NULL) && (mCurTypeInstance->IsTypeAlias()) && (mCurTypeInstance->IsGenericTypeInstance()))
|
||||
{
|
||||
// Don't validate constraints during the population of a concrete generic type alias instance, we want to
|
||||
// throw those errors at the usage sites
|
||||
|
@ -327,8 +327,12 @@ bool BfModule::ValidateGenericConstraints(BfTypeReference* typeRef, BfTypeInstan
|
|||
auto underlyingType = genericTypeInst->GetUnderlyingType();
|
||||
if ((underlyingType != NULL) && (underlyingType->IsGenericTypeInstance()))
|
||||
{
|
||||
auto underlyingGenericType = underlyingType->ToGenericTypeInstance();
|
||||
PopulateType(underlyingType, BfPopulateType_Declaration);
|
||||
return ValidateGenericConstraints(typeRef, (BfTypeInstance*)underlyingType, ignoreErrors);
|
||||
bool result = ValidateGenericConstraints(typeRef, underlyingGenericType, ignoreErrors);
|
||||
if (underlyingGenericType->mGenericTypeInfo->mHadValidateErrors)
|
||||
genericTypeInst->mGenericTypeInfo->mHadValidateErrors = true;
|
||||
return result;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -7285,7 +7289,7 @@ BfType* BfModule::ResolveTypeResult(BfTypeReference* typeRef, BfType* resolvedTy
|
|||
if (curGenericTypeInstance->mGenericTypeInfo->mHadValidateErrors)
|
||||
doValidate = false;
|
||||
}
|
||||
if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mCurBaseTypeRef != NULL)) // We validate constraints for base types later
|
||||
if ((mContext->mCurTypeState != NULL) && (mContext->mCurTypeState->mCurBaseTypeRef != NULL) && (!mContext->mCurTypeState->mTypeInstance->IsTypeAlias())) // We validate constraints for base types later
|
||||
doValidate = false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue