Skip to content

Commit d6a4a35

Browse files
Merge pull request swiftlang#73117 from cachemeifyoucan/eng/PR-testable-lookup-cleanup
[ScanDependency][NFC] Code clean up for testable module lookup
2 parents 9fdb0e7 + 9479daf commit d6a4a35

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/Serialization/ScanningLoaders.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory(
5353
auto ModPath = BaseName.getName(file_types::TY_SwiftModuleFile);
5454
auto InPath = BaseName.findInterfacePath(fs, Ctx);
5555

56-
if (LoadMode == ModuleLoadingMode::OnlySerialized || !InPath) {
56+
// Lookup binary module if it is a testable lookup, or only binary module
57+
// lookup, or interface file does not exist.
58+
if (LoadMode == ModuleLoadingMode::OnlySerialized ||
59+
isTestableDependencyLookup || !InPath) {
5760
if (fs.exists(ModPath)) {
5861
// The module file will be loaded directly.
5962
auto dependencies =
@@ -271,10 +274,6 @@ ModuleDependencyVector SerializedModuleLoaderBase::getModuleDependencies(
271274
auto modulePath = builder.get();
272275
auto moduleId = modulePath.front().Item;
273276

274-
// Do not load interface module if it is testable import.
275-
ModuleLoadingMode MLM =
276-
isTestableDependencyLookup ? ModuleLoadingMode::OnlySerialized : LoadMode;
277-
278277
// Instantiate dependency scanning "loaders".
279278
SmallVector<std::unique_ptr<SwiftModuleScanner>, 2> scanners;
280279
// Placeholder dependencies must be resolved first, to prevent the
@@ -283,10 +282,10 @@ ModuleDependencyVector SerializedModuleLoaderBase::getModuleDependencies(
283282
// dependency graph of the placeholder dependency module itself.
284283
// FIXME: submodules?
285284
scanners.push_back(std::make_unique<PlaceholderSwiftModuleScanner>(
286-
Ctx, MLM, moduleId, Ctx.SearchPathOpts.PlaceholderDependencyModuleMap,
285+
Ctx, LoadMode, moduleId, Ctx.SearchPathOpts.PlaceholderDependencyModuleMap,
287286
delegate, moduleOutputPath));
288287
scanners.push_back(std::make_unique<SwiftModuleScanner>(
289-
Ctx, MLM, moduleId, delegate, moduleOutputPath,
288+
Ctx, LoadMode, moduleId, delegate, moduleOutputPath,
290289
SwiftModuleScanner::MDS_plain));
291290

292291
// Check whether there is a module with this name that we can import.

0 commit comments

Comments
 (0)