diff --git a/lib/AST/Module.cpp b/lib/AST/Module.cpp index db15aa540fa64..ab9db5e738ae9 100644 --- a/lib/AST/Module.cpp +++ b/lib/AST/Module.cpp @@ -1128,6 +1128,9 @@ void ModuleDecl::getDisplayDecls(SmallVectorImpl &Results, bool Recursive llvm::SmallDenseMap, 4> QualifiedImports; collectParsedExportedImports(this, Modules, QualifiedImports); for (const auto &QI : QualifiedImports) { + auto Module = QI.getFirst(); + if (Modules.contains(Module)) continue; + auto &Decls = QI.getSecond(); Results.append(Decls.begin(), Decls.end()); } diff --git a/test/SymbolGraph/Module/DuplicateExportedImport.swift b/test/SymbolGraph/Module/DuplicateExportedImport.swift new file mode 100644 index 0000000000000..174cdc105ec60 --- /dev/null +++ b/test/SymbolGraph/Module/DuplicateExportedImport.swift @@ -0,0 +1,11 @@ +// RUN: %empty-directory(%t) +// RUN: %target-swift-frontend %S/Inputs/DuplicateExportedImport/A.swift -module-name A -emit-module -emit-module-path %t/A.swiftmodule +// RUN: %target-swift-frontend %s -module-name DuplicateExportedImport -emit-module -emit-module-path /dev/null -I %t -emit-symbol-graph -emit-symbol-graph-dir %t/ +// RUN: %FileCheck %s --input-file %t/DuplicateExportedImport.symbols.json + +// REQUIRES: asserts + +// CHECK-COUNT-1: "precise":"s:1A8ClassTwoC" + +@_exported import A +@_exported import class A.ClassTwo diff --git a/test/SymbolGraph/Module/Inputs/DuplicateExportedImport/A.swift b/test/SymbolGraph/Module/Inputs/DuplicateExportedImport/A.swift new file mode 100644 index 0000000000000..8733c3c56bed6 --- /dev/null +++ b/test/SymbolGraph/Module/Inputs/DuplicateExportedImport/A.swift @@ -0,0 +1,3 @@ +public class ClassOne {} + +public class ClassTwo {}