From ee3aa7fc26b16798326d53945efbded1daec9795 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 28 May 2025 07:30:35 +0200 Subject: [PATCH] Fixed IsTypeUsed check for generic parameterized by interfaces --- IDEHelper/Compiler/BfCompiler.cpp | 15 ++++++++------- IDEHelper/Compiler/BfCompiler.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/IDEHelper/Compiler/BfCompiler.cpp b/IDEHelper/Compiler/BfCompiler.cpp index fa985b46..6f650687 100644 --- a/IDEHelper/Compiler/BfCompiler.cpp +++ b/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()) { diff --git a/IDEHelper/Compiler/BfCompiler.h b/IDEHelper/Compiler/BfCompiler.h index 4a0974fd..fc39436c 100644 --- a/IDEHelper/Compiler/BfCompiler.h +++ b/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& foundStringIds, HashSet& dllNameSet, Array& dllMethods, Array& stringValueEntries);