Skip to content

Commit 0609dfc

Browse files
committed
[ModuleInterface] Don't alias the import if it was skipped
1 parent a91bb49 commit 0609dfc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/Frontend/ModuleInterfaceSupport.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,9 @@ static void diagnoseScopedImports(DiagnosticEngine &diags,
212212
/// source declarations.
213213
static void printImports(raw_ostream &out,
214214
ModuleInterfaceOptions const &Opts,
215-
ModuleDecl *M) {
215+
ModuleDecl *M,
216+
const llvm::SmallSet<StringRef, 4>
217+
&AliasModuleNamesTargets) {
216218
// FIXME: This is very similar to what's in Serializer::writeInputBlock, but
217219
// it's not obvious what higher-level optimization would be factored out here.
218220
ModuleDecl::ImportFilter allImportFilter = {
@@ -322,7 +324,8 @@ static void printImports(raw_ostream &out,
322324
}
323325

324326
out << "import ";
325-
if (Opts.AliasModuleNames)
327+
if (Opts.AliasModuleNames &&
328+
AliasModuleNamesTargets.contains(importedModule->getName().str()))
326329
out << MODULE_DISAMBIGUATING_PREFIX;
327330
importedModule->getReverseFullModuleName().printForward(out);
328331

@@ -786,7 +789,7 @@ bool swift::emitSwiftInterface(raw_ostream &out,
786789
llvm::SmallSet<StringRef, 4> aliasModuleNamesTargets;
787790
printToolVersionAndFlagsComment(out, Opts, M, aliasModuleNamesTargets);
788791

789-
printImports(out, Opts, M);
792+
printImports(out, Opts, M, aliasModuleNamesTargets);
790793

791794
static bool forceUseExportedModuleNameInPublicOnly =
792795
getenv("SWIFT_DEBUG_USE_EXPORTED_MODULE_NAME_IN_PUBLIC_ONLY");

0 commit comments

Comments
 (0)