[Serialization] Refactor logic deciding transitive module loading logic

Refactor and centralize the logic about how implementation-only and
package-only dependencies should be loaded.
This commit is contained in:
Alexis Laferrière
2023-03-15 22:19:21 -07:00
parent 2bc92a6a59
commit 61c0827427
5 changed files with 99 additions and 21 deletions

View File

@@ -940,10 +940,11 @@ void swift::serialization::diagnoseSerializedASTLoadFailure(
std::copy_if(
loadedModuleFile->getDependencies().begin(),
loadedModuleFile->getDependencies().end(), std::back_inserter(missing),
[&duplicates, &Ctx](const ModuleFile::Dependency &dependency) -> bool {
[&duplicates, &loadedModuleFile](
const ModuleFile::Dependency &dependency) -> bool {
if (dependency.isLoaded() || dependency.isHeader() ||
(dependency.isImplementationOnly() &&
Ctx.LangOpts.DebuggerSupport)) {
loadedModuleFile->getTransitiveLoadingBehavior(dependency) !=
ModuleLoadingBehavior::Required) {
return false;
}
return duplicates.insert(dependency.Core.RawPath).second;