@@ -212,7 +212,9 @@ static void diagnoseScopedImports(DiagnosticEngine &diags,
212
212
// / source declarations.
213
213
static void printImports (raw_ostream &out,
214
214
ModuleInterfaceOptions const &Opts,
215
- ModuleDecl *M) {
215
+ ModuleDecl *M,
216
+ const llvm::SmallSet<StringRef, 4 >
217
+ &AliasModuleNamesTargets) {
216
218
// FIXME: This is very similar to what's in Serializer::writeInputBlock, but
217
219
// it's not obvious what higher-level optimization would be factored out here.
218
220
ModuleDecl::ImportFilter allImportFilter = {
@@ -322,7 +324,8 @@ static void printImports(raw_ostream &out,
322
324
}
323
325
324
326
out << " import " ;
325
- if (Opts.AliasModuleNames )
327
+ if (Opts.AliasModuleNames &&
328
+ AliasModuleNamesTargets.contains (importedModule->getName ().str ()))
326
329
out << MODULE_DISAMBIGUATING_PREFIX;
327
330
importedModule->getReverseFullModuleName ().printForward (out);
328
331
@@ -786,7 +789,7 @@ bool swift::emitSwiftInterface(raw_ostream &out,
786
789
llvm::SmallSet<StringRef, 4 > aliasModuleNamesTargets;
787
790
printToolVersionAndFlagsComment (out, Opts, M, aliasModuleNamesTargets);
788
791
789
- printImports (out, Opts, M);
792
+ printImports (out, Opts, M, aliasModuleNamesTargets );
790
793
791
794
static bool forceUseExportedModuleNameInPublicOnly =
792
795
getenv (" SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY" );
0 commit comments