Add a check for an empty package interface path

Update diags
This commit is contained in:
Ellie Shin
2023-11-14 01:07:28 -08:00
parent 9d716394b1
commit fbdc16d69a
4 changed files with 4 additions and 4 deletions

View File

@@ -1110,7 +1110,7 @@ ERROR(in_package_module_not_compiled_from_source_or_package_interface,none,
WARNING(in_package_module_not_compiled_locally,none,
"module %0 is in package %1 but was loaded from SDK; "
"modules of the same package should be built locally: %2",
"modules of the same package should be built locally from source only: %2",
(Identifier, Identifier, StringRef))
ERROR(import_restriction_conflict,none,

View File

@@ -70,7 +70,7 @@ std::error_code SwiftModuleScanner::findModuleFilesInDirectory(
// Use package.swiftinterface if it exists and its package-name applies to
// the importer module.
auto PkgInPath = BaseName.getPackageInterfacePathIfInSamePackage(fs, Ctx).value_or("");
if (fs.exists(PkgInPath)) {
if (!PkgInPath.empty() && fs.exists(PkgInPath)) {
InPath = PkgInPath;
} else {
// If not in package, use the private interface file if exits.

View File

@@ -641,7 +641,7 @@ SerializedModuleBaseName::findInterfacePath(llvm::vfs::FileSystem &fs, ASTContex
// Check if a package interface exists and if the package name applies to
// the importer module.
auto pkgPath = getPackageInterfacePathIfInSamePackage(fs, ctx).value_or("");
if (fs.exists(pkgPath))
if (!pkgPath.empty() && fs.exists(pkgPath))
return pkgPath;
// If above fails, use the existing logic as fallback.

View File

@@ -29,7 +29,7 @@
package func log(level: Int) {}
//--- Client1.swift
import LibInSDK // expected-warning {{module 'LibInSDK' is in package 'libPkg' but was loaded from SDK; modules of the same package should be built locally}}
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}}
func someFunc() {
log(level: 1)