1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

Improved handling of multiple declarations of required system types

This commit is contained in:
Brian Fiete 2025-05-12 10:32:45 +02:00
parent 2e9a2f3eb3
commit 2f6d9e03ab

View file

@ -7223,14 +7223,32 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
//HashSet<BfTypeDef*> internalTypeDefs;
BfProject* corlibProject = NULL;
auto _GetRequiredType = [&](const StringImpl& typeName, int genericArgCount = 0)
{
auto typeDef = mSystem->FindTypeDef(typeName, genericArgCount);
BfTypeDef* ambigiousTypeDef = NULL;
auto typeDef = mSystem->FindTypeDef(typeName, genericArgCount, NULL, {}, &ambigiousTypeDef);
if (typeDef == NULL)
{
mPassInstance->Fail(StrFormat("Unable to find system type: %s", typeName.c_str()));
mHasRequiredTypes = false;
}
if (ambigiousTypeDef != NULL)
{
mPassInstance->Fail(StrFormat("Found multiple declarations of require type '%s'", typeName.c_str()), typeDef->GetRefNode());
mPassInstance->MoreInfo("See additional declaration", ambigiousTypeDef->GetRefNode());
if (typeDef->mProject != corlibProject)
{
auto rootTypeDef = mSystem->FindTypeDef(typeName, genericArgCount, corlibProject);
if (rootTypeDef != NULL)
typeDef = rootTypeDef;
}
}
if (corlibProject == NULL)
corlibProject = typeDef->mProject;
return typeDef;
};