Skip to content

Commit 53ad5de

Browse files
Revert "[ScanDependency] Allow importing binary testable module when no interface"
This reverts commit 90a1586.
1 parent bc4eeb8 commit 53ad5de

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

include/swift/Serialization/SerializedModuleLoader.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,8 @@ class SerializedModuleLoaderBase : public ModuleLoader {
163163
}
164164

165165
/// Scan the given serialized module file to determine dependencies.
166-
llvm::ErrorOr<ModuleDependencyInfo> scanModuleFile(Twine modulePath,
167-
bool isFramework,
168-
bool isTestableImport,
169-
bool hasInterface);
166+
llvm::ErrorOr<ModuleDependencyInfo>
167+
scanModuleFile(Twine modulePath, bool isFramework, bool isTestableImport);
170168

171169
struct BinaryModuleImports {
172170
llvm::StringSet<> moduleImports;

lib/Serialization/ScanningLoaders.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory(
5757
if (fs.exists(ModPath)) {
5858
// The module file will be loaded directly.
5959
auto dependencies =
60-
scanModuleFile(ModPath, IsFramework, isTestableDependencyLookup,
61-
/*hasInterface=*/false);
60+
scanModuleFile(ModPath, IsFramework, isTestableDependencyLookup);
6261
if (dependencies) {
6362
this->dependencies = std::move(dependencies.get());
6463
return std::error_code();
@@ -160,9 +159,8 @@ SwiftModuleScanner::scanInterfaceFile(Twine moduleInterfacePath,
160159
!Ctx.SearchPathOpts.NoScannerModuleValidation) {
161160
assert(compiledCandidates.size() == 1 &&
162161
"Should only have 1 candidate module");
163-
auto BinaryDep =
164-
scanModuleFile(compiledCandidates[0], isFramework,
165-
isTestableImport, /*hasInterface=*/true);
162+
auto BinaryDep = scanModuleFile(compiledCandidates[0], isFramework,
163+
isTestableImport);
166164
if (BinaryDep) {
167165
Result = *BinaryDep;
168166
return std::error_code();

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,7 @@ SerializedModuleLoaderBase::getImportsOfModule(
431431

432432
llvm::ErrorOr<ModuleDependencyInfo>
433433
SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
434-
bool isTestableImport,
435-
bool hasInterface) {
434+
bool isTestableImport) {
436435
const std::string moduleDocPath;
437436
const std::string sourceInfoPath;
438437

@@ -456,10 +455,7 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
456455
return std::make_error_code(std::errc::no_such_file_or_directory);
457456
}
458457

459-
// If the module file has interface file and not testable imported, don't
460-
// import the testable module because it contains more interfaces than
461-
// needed and can pull in more dependencies.
462-
if (loadedModuleFile->isTestable() && !isTestableImport && hasInterface) {
458+
if (loadedModuleFile->isTestable() && !isTestableImport) {
463459
if (Ctx.LangOpts.EnableModuleLoadingRemarks)
464460
Ctx.Diags.diagnose(SourceLoc(), diag::skip_module_testable,
465461
modulePath.str());

test/ScanDependencies/testable-dependencies.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@
5656
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib -enable-testing \
5757
// RUN: -o %t/deps5.json -I %t/regular -swift-version 5 -Rmodule-loading
5858

59-
/// Regular import a testable module with no interface, will try to import binary module but fail to look up the dependency.
59+
/// Regular import a testable module with no interface, this is a dependency scanning error.
6060
// RUN: rm %t/testable/A.swiftinterface
6161
// RUN: %target-swift-frontend -scan-dependencies -module-load-mode prefer-interface -module-name Test %t/main.swift \
6262
// RUN: -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import -parse-stdlib -enable-testing \
6363
// RUN: -o %t/deps6.json -I %t/testable -swift-version 5 -Rmodule-loading 2>&1 | %FileCheck %s --check-prefix ERROR
64-
// ERROR: error: Unable to find module dependency: 'B'
64+
// ERROR: error: Unable to find module dependency: 'A'
6565

6666
//--- main.swift
6767
import A

0 commit comments

Comments
 (0)