Parcourir la source

Improved handling of multiple declarations of required system types

Brian Fiete il y a 2 mois
Parent
commit
2f6d9e03ab
1 fichiers modifiés avec 19 ajouts et 1 suppressions
  1. 19 1
      IDEHelper/Compiler/BfCompiler.cpp

+ 19 - 1
IDEHelper/Compiler/BfCompiler.cpp

@@ -7222,15 +7222,33 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
 	mHasRequiredTypes = true;
 
 	//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;
 	};