@@ -1214,12 +1214,22 @@ std::error_code ModuleInterfaceLoader::findModuleFilesInDirectory(
12141214}
12151215
12161216std::vector<std::string>
1217- ModuleInterfaceCheckerImpl::getCompiledModuleCandidatesForInterface (
1218- StringRef moduleName, StringRef interfacePath) {
1217+ ModuleInterfaceCheckerImpl::getCompiledModuleCandidatesForInterface (StringRef moduleName, StringRef interfacePath) {
12191218 // Derive .swiftmodule path from the .swiftinterface path.
1219+ auto interfaceExt = file_types::getExtension (file_types::TY_SwiftModuleInterfaceFile);
12201220 auto newExt = file_types::getExtension (file_types::TY_SwiftModuleFile);
1221- llvm::SmallString<32 > modulePath = interfacePath;
1222- llvm::sys::path::replace_extension (modulePath, newExt);
1221+ llvm::SmallString<32 > modulePath;
1222+
1223+ // When looking up the module for a private interface, strip the '.private.' section of the base name
1224+ if (interfacePath.endswith (" .private." + interfaceExt.str ())) {
1225+ auto newBaseName = llvm::sys::path::stem (llvm::sys::path::stem (interfacePath));
1226+ modulePath = llvm::sys::path::parent_path (interfacePath);
1227+ llvm::sys::path::append (modulePath, newBaseName + " ." + newExt.str ());
1228+ } else {
1229+ modulePath = interfacePath;
1230+ llvm::sys::path::replace_extension (modulePath, newExt);
1231+ }
1232+
12231233 ModuleInterfaceLoaderImpl Impl (Ctx, modulePath, interfacePath, moduleName,
12241234 CacheDir, PrebuiltCacheDir, BackupInterfaceDir,
12251235 SourceLoc (), Opts,
0 commit comments