Skip to content

Commit fbdc16d

Browse files
committed
Add a check for an empty package interface path
Update diags
1 parent 9d71639 commit fbdc16d

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,7 @@ ERROR(in_package_module_not_compiled_from_source_or_package_interface,none,
11101110

11111111
WARNING(in_package_module_not_compiled_locally,none,
11121112
"module %0 is in package %1 but was loaded from SDK; "
1113-
"modules of the same package should be built locally: %2",
1113+
"modules of the same package should be built locally from source only: %2",
11141114
(Identifier, Identifier, StringRef))
11151115

11161116
ERROR(import_restriction_conflict,none,

lib/Serialization/ScanningLoaders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory(
7070
// Use package.swiftinterface if it exists and its package-name applies to
7171
// the importer module.
7272
auto PkgInPath = BaseName.getPackageInterfacePathIfInSamePackage(fs, Ctx).value_or("");
73-
if (fs.exists(PkgInPath)) {
73+
if (!PkgInPath.empty() && fs.exists(PkgInPath)) {
7474
InPath = PkgInPath;
7575
} else {
7676
// If not in package, use the private interface file if exits.

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ SerializedModuleBaseName::findInterfacePath(llvm::vfs::FileSystem &fs, ASTContex
641641
// Check if a package interface exists and if the package name applies to
642642
// the importer module.
643643
auto pkgPath = getPackageInterfacePathIfInSamePackage(fs, ctx).value_or("");
644-
if (fs.exists(pkgPath))
644+
if (!pkgPath.empty() && fs.exists(pkgPath))
645645
return pkgPath;
646646

647647
// If above fails, use the existing logic as fallback.

test/Sema/import_package_module_from_sdk.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
package func log(level: Int) {}
3030

3131
//--- Client1.swift
32-
import LibInSDK // expected-warning {{module 'LibInSDK' is in package 'libPkg' but was loaded from SDK; modules of the same package should be built locally}}
32+
import LibInSDK // expected-warning {{module 'LibInSDK' is in package 'libPkg' but was loaded from SDK; modules of the same package should be built locally from source only}}
3333

3434
func someFunc() {
3535
log(level: 1)

0 commit comments

Comments
 (0)