[Serialization] Differentiate module loading behavior for non-public imports

Differentiate `internal` and `fileprivate` imports from
implementation-only imports at the module-wide level to offer a
different module loading strategy. The main difference is for non-public
imports from a module with testing enabled to be loaded by transitive
clients.

Ideally, we would only load transitive non-public dependencies on
testable imports of the middle module. The current module loading logic
doesn't allow for this behavior easily as a module may be first loaded
for a normal import and extra dependencies would have to be loaded on
later imports. We may want to refactor the module loading logic to allow
this if needed.

rdar://106514965
This commit is contained in:
Alexis Laferrière
2023-03-15 22:09:31 -07:00
parent d7cd65cdd6
commit 599346885e
10 changed files with 91 additions and 20 deletions

View File

@@ -468,6 +468,10 @@ void ModuleFile::getImportedModules(SmallVectorImpl<ImportedModule> &results,
continue;
}
} else if (dep.isInternalOrBelow()) {
if (!filter.contains(ModuleDecl::ImportFilterKind::InternalOrBelow))
continue;
} else if (dep.isPackageOnly()) {
if (!filter.contains(ModuleDecl::ImportFilterKind::PackageOnly))
continue;