Browse Source

Fixed IsTypeUsed check for generic parameterized by interfaces

Brian Fiete 2 months ago
parent
commit
ee3aa7fc26
2 changed files with 9 additions and 8 deletions
  1. 8 7
      IDEHelper/Compiler/BfCompiler.cpp
  2. 1 1
      IDEHelper/Compiler/BfCompiler.h

+ 8 - 7
IDEHelper/Compiler/BfCompiler.cpp

@@ -545,7 +545,7 @@ bool BfCompiler::IsTypeAccessible(BfType* checkType, BfProject* curProject)
 	return true;
 }
 
-bool BfCompiler::IsTypeUsed(BfType* checkType, BfProject* curProject)
+bool BfCompiler::IsTypeUsed(BfType* checkType, BfProject* curProject, bool conservativeCheck)
 {
 	if (mOptions.mCompileOnDemandKind == BfCompileOnDemandKind_AlwaysInclude)
 		return IsTypeAccessible(checkType, curProject);
@@ -561,17 +561,17 @@ bool BfCompiler::IsTypeUsed(BfType* checkType, BfProject* curProject)
 // 		}
 
 		if (checkType->IsInterface())
-			return typeInst->mIsReified;
+			return typeInst->mIsReified || conservativeCheck;
 
 		//TODO: We could check to see if this project has any reified specialized instances...
 		if (checkType->IsUnspecializedType())
-			return typeInst->mIsReified;
+			return typeInst->mIsReified || conservativeCheck;
 
 		if (checkType->IsTuple())
 		{
 			for (auto&& fieldInst : typeInst->mFieldInstances)
 			{
-				if (!IsTypeUsed(fieldInst.mResolvedType, curProject))
+				if (!IsTypeUsed(fieldInst.mResolvedType, curProject, true))
 					return false;
 			}
 		}
@@ -580,7 +580,7 @@ bool BfCompiler::IsTypeUsed(BfType* checkType, BfProject* curProject)
 		if (genericTypeInst != NULL)
 		{
 			for (auto genericArg : genericTypeInst->mGenericTypeInfo->mTypeGenericArguments)
-				if (!IsTypeUsed(genericArg, curProject))
+				if (!IsTypeUsed(genericArg, curProject, true))
 					return false;
 		}
 
@@ -1264,8 +1264,9 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
 			continue;
 
 		auto typeInst = type->ToTypeInstance();
+
 		if ((typeInst != NULL) && (!typeInst->IsReified()) && (!typeInst->IsUnspecializedType()))
-			continue;
+			continue;		
 
 		if (!IsTypeUsed(type, project))
 			continue;
@@ -1279,7 +1280,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
 		{
 			auto module = typeInst->mModule;
 			if (module == NULL)
-				continue;
+				continue;			
 
 			if (type->IsEnum())
 			{

+ 1 - 1
IDEHelper/Compiler/BfCompiler.h

@@ -477,7 +477,7 @@ public:
 
 public:
 	bool IsTypeAccessible(BfType* checkType, BfProject* curProject);
-	bool IsTypeUsed(BfType* checkType, BfProject* curProject);
+	bool IsTypeUsed(BfType* checkType, BfProject* curProject, bool conservativeCheck = false);
 	bool IsModuleAccessible(BfModule* module, BfProject* curProject);
 	void FixVDataHash(BfModule* bfModule);
 	void CheckModuleStringRefs(BfModule* module, BfVDataModule* vdataModule, int lastModuleRevision, HashSet<int>& foundStringIds, HashSet<int>& dllNameSet, Array<BfMethodInstance*>& dllMethods, Array<BfCompiler::StringValueEntry>& stringValueEntries);