@@ -80,8 +80,7 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory(
80
80
InPath = PrivateInPath;
81
81
}
82
82
}
83
- auto dependencies =
84
- scanInterfaceFile (InPath, IsFramework, isTestableDependencyLookup);
83
+ auto dependencies = scanInterfaceFile (InPath, IsFramework);
85
84
if (dependencies) {
86
85
this ->dependencies = std::move (dependencies.get ());
87
86
return std::error_code ();
@@ -148,7 +147,7 @@ static std::vector<std::string> getCompiledCandidates(ASTContext &ctx,
148
147
149
148
llvm::ErrorOr<ModuleDependencyInfo>
150
149
SwiftModuleScanner::scanInterfaceFile (Twine moduleInterfacePath,
151
- bool isFramework, bool isTestableImport ) {
150
+ bool isFramework) {
152
151
// Create a module filename.
153
152
// FIXME: Query the module interface loader to determine an appropriate
154
153
// name for the module, which includes an appropriate hash.
@@ -242,64 +241,6 @@ SwiftModuleScanner::scanInterfaceFile(Twine moduleInterfacePath,
242
241
&alreadyAddedModules);
243
242
}
244
243
245
- // For a `@testable` direct dependency, read in the dependencies
246
- // from an adjacent binary module, for completeness.
247
- if (isTestableImport) {
248
- auto adjacentBinaryModule = std::find_if (
249
- compiledCandidates.begin (), compiledCandidates.end (),
250
- [moduleInterfacePath](const std::string &candidate) {
251
- return llvm::sys::path::parent_path (candidate) ==
252
- llvm::sys::path::parent_path (moduleInterfacePath.str ());
253
- });
254
- if (adjacentBinaryModule != compiledCandidates.end ()) {
255
- // Required modules.
256
- auto adjacentBinaryModuleRequiredImports = getImportsOfModule (
257
- *adjacentBinaryModule, ModuleLoadingBehavior::Required,
258
- isFramework, isRequiredOSSAModules (),
259
- isRequiredNoncopyableGenerics (),
260
- Ctx.LangOpts .SDKName ,
261
- Ctx.LangOpts .PackageName , Ctx.SourceMgr .getFileSystem ().get (),
262
- Ctx.SearchPathOpts .DeserializedPathRecoverer );
263
- if (!adjacentBinaryModuleRequiredImports)
264
- return adjacentBinaryModuleRequiredImports.getError ();
265
- auto adjacentBinaryModuleRequiredModuleImports =
266
- (*adjacentBinaryModuleRequiredImports).moduleImports ;
267
- #ifndef NDEBUG
268
- // Verify that the set of required modules read out from the binary
269
- // module is a super-set of module imports identified in the
270
- // textual interface.
271
- for (const auto &requiredImport : Result->getModuleImports ()) {
272
- assert (
273
- adjacentBinaryModuleRequiredModuleImports.contains (
274
- requiredImport) &&
275
- " Expected adjacent binary module's import set to contain all "
276
- " textual interface imports." );
277
- }
278
- #endif
279
-
280
- for (const auto &requiredImport :
281
- adjacentBinaryModuleRequiredModuleImports)
282
- Result->addModuleImport (requiredImport.getKey (),
283
- &alreadyAddedModules);
284
-
285
- // Optional modules. Will be looked-up on a best-effort basis
286
- auto adjacentBinaryModuleOptionalImports = getImportsOfModule (
287
- *adjacentBinaryModule, ModuleLoadingBehavior::Optional,
288
- isFramework, isRequiredOSSAModules (),
289
- isRequiredNoncopyableGenerics (), Ctx.LangOpts .SDKName ,
290
- Ctx.LangOpts .PackageName , Ctx.SourceMgr .getFileSystem ().get (),
291
- Ctx.SearchPathOpts .DeserializedPathRecoverer );
292
- if (!adjacentBinaryModuleOptionalImports)
293
- return adjacentBinaryModuleOptionalImports.getError ();
294
- auto adjacentBinaryModuleOptionalModuleImports =
295
- (*adjacentBinaryModuleOptionalImports).moduleImports ;
296
- for (const auto &optionalImport :
297
- adjacentBinaryModuleOptionalModuleImports)
298
- Result->addOptionalModuleImport (optionalImport.getKey (),
299
- &alreadyAddedModules);
300
- }
301
- }
302
-
303
244
return std::error_code ();
304
245
});
305
246
@@ -324,6 +265,10 @@ ModuleDependencyVector SerializedModuleLoaderBase::getModuleDependencies(
324
265
if (CacheFS)
325
266
tracker = SwiftDependencyTracker (*CacheFS, mapper);
326
267
268
+ // Do not load interface module if it is testable import.
269
+ ModuleLoadingMode MLM =
270
+ isTestableDependencyLookup ? ModuleLoadingMode::OnlySerialized : LoadMode;
271
+
327
272
// Instantiate dependency scanning "loaders".
328
273
SmallVector<std::unique_ptr<SwiftModuleScanner>, 2 > scanners;
329
274
// Placeholder dependencies must be resolved first, to prevent the
@@ -332,11 +277,10 @@ ModuleDependencyVector SerializedModuleLoaderBase::getModuleDependencies(
332
277
// dependency graph of the placeholder dependency module itself.
333
278
// FIXME: submodules?
334
279
scanners.push_back (std::make_unique<PlaceholderSwiftModuleScanner>(
335
- Ctx, LoadMode, moduleId,
336
- Ctx.SearchPathOpts .PlaceholderDependencyModuleMap , delegate,
337
- moduleOutputPath, tracker));
280
+ Ctx, MLM, moduleId, Ctx.SearchPathOpts .PlaceholderDependencyModuleMap ,
281
+ delegate, moduleOutputPath, tracker));
338
282
scanners.push_back (std::make_unique<SwiftModuleScanner>(
339
- Ctx, LoadMode , moduleId, delegate, moduleOutputPath,
283
+ Ctx, MLM , moduleId, delegate, moduleOutputPath,
340
284
SwiftModuleScanner::MDS_plain, tracker));
341
285
342
286
// Check whether there is a module with this name that we can import.
0 commit comments