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

Improvements to failed extension, fixed protection on extended types

This commit is contained in:
Brian Fiete 2022-02-22 07:41:05 -08:00
parent 0a856c91ff
commit c91c81f77d
2 changed files with 15 additions and 8 deletions

View file

@ -3578,13 +3578,16 @@ void BfCompiler::UpdateRevisedTypes()
if (failedToFindRootType) if (failedToFindRootType)
{ {
for (auto partialTypeDecl : compositeTypeDef->GetLatest()->mPartials) for (auto partialTypeDef : compositeTypeDef->GetLatest()->mPartials)
{ {
// Couldn't find a root type def, treat ourselves as an explicit partial if (partialTypeDef->IsExtension())
auto error = mPassInstance->Fail(StrFormat("Unable to find root type definition for extension '%s'", partialTypeDecl->GetLatest()->mFullName.ToString().c_str()), {
partialTypeDecl->GetLatest()->mTypeDeclaration->mNameNode); // Couldn't find a root type def, treat ourselves as an explicit partial
if (error != NULL) auto error = mPassInstance->Fail(StrFormat("Unable to find root type definition for extension '%s'", BfTypeUtils::TypeToString(partialTypeDef->GetLatest()).c_str()),
error->mIsPersistent = true; partialTypeDef->GetLatest()->mTypeDeclaration->mNameNode);
if (error != NULL)
error->mIsPersistent = true;
}
} }
} }
} }

View file

@ -2597,6 +2597,11 @@ bool BfSystem::FindTypeDef(const BfAtomComposite& findName, int numGenericArgs,
// Still allow SOME match even if we put in the wrong number of generic args // Still allow SOME match even if we put in the wrong number of generic args
curPri -= 4; curPri -= 4;
} }
if ((typeDef->mPartials.mSize > 0) && (typeDef->mPartials[0]->IsExtension()))
{
// Is a failed extension
curPri -= 8;
}
if ((curPri > ctx->mBestPri) || (ctx->mBestTypeDef == NULL)) if ((curPri > ctx->mBestPri) || (ctx->mBestTypeDef == NULL))
{ {
@ -3059,8 +3064,7 @@ void BfSystem::AddToCompositePartial(BfPassInstance* passInstance, BfTypeDef* co
typeDef->mHasCEOnCompile |= partialTypeDef->mHasCEOnCompile; typeDef->mHasCEOnCompile |= partialTypeDef->mHasCEOnCompile;
typeDef->mHasExtensionMethods |= partialTypeDef->mHasExtensionMethods; typeDef->mHasExtensionMethods |= partialTypeDef->mHasExtensionMethods;
typeDef->mHasUsingFields |= partialTypeDef->mHasUsingFields; typeDef->mHasUsingFields |= partialTypeDef->mHasUsingFields;
typeDef->mHasOverrideMethods |= partialTypeDef->mHasOverrideMethods; typeDef->mHasOverrideMethods |= partialTypeDef->mHasOverrideMethods;
typeDef->mProtection = BF_MIN(typeDef->mProtection, partialTypeDef->mProtection);
for (auto innerType : partialTypeDef->mNestedTypes) for (auto innerType : partialTypeDef->mNestedTypes)
{ {