Skip to content

Commit 255a094

Browse files
committed
Correct discrepancies in the package interface file lookup.
Add a check for the client side flag which explcitly opts in to loading the package interface, besides whether package-name is empty or in the same package. rdar://131393508
1 parent bbc02a5 commit 255a094

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,6 @@ std::string SerializedModuleBaseName::getName(file_types::ID fileTy) const {
618618
std::optional<std::string>
619619
SerializedModuleBaseName::getPackageInterfacePathIfInSamePackage(
620620
llvm::vfs::FileSystem &fs, ASTContext &ctx) const {
621-
if (!ctx.LangOpts.EnablePackageInterfaceLoad)
622-
return std::nullopt;
623-
624621
std::string packagePath{
625622
getName(file_types::TY_PackageSwiftModuleInterfaceFile)};
626623

@@ -667,8 +664,12 @@ SerializedModuleBaseName::findInterfacePath(llvm::vfs::FileSystem &fs,
667664
if (!fs.exists(interfacePath))
668665
return std::nullopt;
669666

670-
// If there is a package name, try look for the package interface.
671-
if (!ctx.LangOpts.PackageName.empty()) {
667+
// If there is a package name, try to look for the package interface,
668+
// which can only be loaded if -experimental-package-interface-load
669+
// is passed to the client, so fall back to private/public interface
670+
// if not.
671+
if (!ctx.LangOpts.PackageName.empty() &&
672+
ctx.LangOpts.EnablePackageInterfaceLoad) {
672673
if (auto maybePackageInterface =
673674
getPackageInterfacePathIfInSamePackage(fs, ctx))
674675
return *maybePackageInterface;

0 commit comments

Comments
 (0)