Skip to content

Commit 99e4fb6

Browse files
don't re-export internal symbols from other modules
1 parent da32971 commit 99e4fb6

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,13 @@ bool SymbolGraph::isImplicitlyPrivate(const Decl *D,
627627

628628
// Special cases below.
629629

630+
// Symbols from exported-imported modules should only be included if they
631+
// were originally public.
632+
if (Walker.isFromExportedImportedModule(D) &&
633+
VD->getFormalAccess() < AccessLevel::Public) {
634+
return true;
635+
}
636+
630637
auto BaseName = VD->getBaseName().userFacingName();
631638

632639
// ${MODULE}Version{Number,String} in ${Module}.h

test/SymbolGraph/Module/NoDocExportedImport.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
// RUN: %FileCheck %s --input-file %t/NoDocExportedImport.symbols.json --check-prefix PUBLIC
77
// RUN: ls %t | %FileCheck %s --check-prefix FILES
88

9+
// RUN: %target-swift-frontend %s -module-name NoDocExportedImport -emit-module -emit-module-path /dev/null -I %t -emit-symbol-graph -emit-symbol-graph-dir %t/ -symbol-graph-minimum-access-level internal
10+
// RUN: %FileCheck %s --input-file %t/NoDocExportedImport.symbols.json --check-prefix INTERNAL
11+
// RUN: ls %t | %FileCheck %s --check-prefix FILES
12+
913
@_nodoc @_exported import A
1014
@_nodoc @_exported import struct B.StructOne
1115

@@ -14,6 +18,11 @@
1418
// PUBLIC-NOT: "precise":"s:1A11SymbolFromAV"
1519
// PUBLIC-NOT: "precise":"s:1B9StructOneV"
1620

21+
// INTERNAL-NOT: InternalSymbolFromA
22+
// INTERNAL-NOT: StructTwo
23+
// INTERNAL-DAG: "precise":"s:1A11SymbolFromAV"
24+
// INTERNAL-DAG: "precise":"s:1B9StructOneV"
25+
1726
// FIXME: Symbols from `@_exported import` do not get emitted when using swift-symbolgraph-extract
1827
// This is tracked by https://bugs.swift.org/browse/SR-15921.
1928

0 commit comments

Comments
 (0)