Skip to content

Commit 1f77f46

Browse files
committed
Report cannot load submodule if only able to load top module
For loaders that don't support loading submodules, canImportModule should report false instead of checking if can import top module.
1 parent 16d204b commit 1f77f46

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,8 @@ bool ExplicitSwiftModuleLoader::canImportModule(ImportPath::Module path,
18491849
llvm::VersionTuple version,
18501850
bool underlyingVersion) {
18511851
// FIXME: Swift submodules?
1852+
if (path.hasSubmodule())
1853+
return false;
18521854
ImportPath::Element mID = path.front();
18531855
// Look up the module with the real name (physical name on disk);
18541856
// in case `-module-alias` is used, the name appearing in source files

lib/Sema/SourceLoader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool SourceLoader::canImportModule(ImportPath::Module path,
7373
llvm::VersionTuple version,
7474
bool underlyingVersion) {
7575
// FIXME: Swift submodules?
76-
if (path.size() > 1)
76+
if (path.hasSubmodule())
7777
return false;
7878

7979
auto ID = path[0];

lib/Serialization/SerializedModuleLoader.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -1133,6 +1133,9 @@ swift::extractUserModuleVersionFromInterface(StringRef moduleInterfacePath) {
11331133
bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
11341134
llvm::VersionTuple version,
11351135
bool underlyingVersion) {
1136+
// FIXME: Swift submodules?
1137+
if (path.hasSubmodule())
1138+
return false;
11361139
// If underlying version is specified, this should be handled by Clang importer.
11371140
if (!version.empty() && underlyingVersion)
11381141
return false;
@@ -1153,7 +1156,6 @@ bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
11531156
unusedModuleDocBuffer = &moduleDocBuffer;
11541157
}
11551158

1156-
// FIXME: Swift submodules?
11571159
auto mID = path[0];
11581160
auto found = findModule(mID, unusedModuleInterfacePath, unusedModuleBuffer,
11591161
unusedModuleDocBuffer, unusedModuleSourceInfoBuffer,
@@ -1192,10 +1194,12 @@ bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
11921194
bool MemoryBufferSerializedModuleLoader::canImportModule(
11931195
ImportPath::Module path, llvm::VersionTuple version,
11941196
bool underlyingVersion) {
1197+
// FIXME: Swift submodules?
1198+
if (path.hasSubmodule())
1199+
return false;
11951200
// If underlying version is specified, this should be handled by Clang importer.
11961201
if (!version.empty() && underlyingVersion)
11971202
return false;
1198-
// FIXME: Swift submodules?
11991203
auto mID = path[0];
12001204
auto mIt = MemoryBuffers.find(mID.Item.str());
12011205
if (mIt == MemoryBuffers.end())

0 commit comments

Comments
 (0)