mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Improved handling of multiple declarations of required system types
This commit is contained in:
parent
2e9a2f3eb3
commit
2f6d9e03ab
1 changed files with 19 additions and 1 deletions
|
@ -7223,14 +7223,32 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
|
|
||||||
//HashSet<BfTypeDef*> internalTypeDefs;
|
//HashSet<BfTypeDef*> internalTypeDefs;
|
||||||
|
|
||||||
|
BfProject* corlibProject = NULL;
|
||||||
|
|
||||||
auto _GetRequiredType = [&](const StringImpl& typeName, int genericArgCount = 0)
|
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)
|
if (typeDef == NULL)
|
||||||
{
|
{
|
||||||
mPassInstance->Fail(StrFormat("Unable to find system type: %s", typeName.c_str()));
|
mPassInstance->Fail(StrFormat("Unable to find system type: %s", typeName.c_str()));
|
||||||
mHasRequiredTypes = false;
|
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;
|
return typeDef;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue