[Serialization] Ignore missing potentially optional dependencies in getImportedModules

The service `ModuleFile::getImportedModules` is called after the
dependency loading logic runs. We can trust this previous logic to have
correctly loaded optional dependencies. In `getImportedModules` we can
just ignore such missing dependencies.

rdar://115372249
This commit is contained in:
Alexis Laferrière
2023-09-12 16:57:02 -07:00
parent 5b8553cbe7
commit 5072b303ff
2 changed files with 9 additions and 8 deletions

View File

@@ -496,20 +496,20 @@ void ModuleFile::getImportedModules(SmallVectorImpl<ImportedModule> &results,
continue;
} else if (dep.isImplementationOnly()) {
if (!filter.contains(ModuleDecl::ImportFilterKind::ImplementationOnly))
// Pretend we didn't have potentially optional imports if we weren't
// originally asked to load it.
if (!filter.contains(ModuleDecl::ImportFilterKind::ImplementationOnly) ||
!dep.isLoaded())
continue;
if (!dep.isLoaded()) {
// Pretend we didn't have this import if we weren't originally asked to
// load it.
continue;
}
} else if (dep.isInternalOrBelow()) {
if (!filter.contains(ModuleDecl::ImportFilterKind::InternalOrBelow))
if (!filter.contains(ModuleDecl::ImportFilterKind::InternalOrBelow) ||
!dep.isLoaded())
continue;
} else if (dep.isPackageOnly()) {
if (!filter.contains(ModuleDecl::ImportFilterKind::PackageOnly))
if (!filter.contains(ModuleDecl::ImportFilterKind::PackageOnly) ||
!dep.isLoaded())
continue;
} else {