Skip to content

Commit 58bbe1e

Browse files
committed
SymbolGraph: Don't unconditionally add edge targets to the graph
Edge targets might point outside the module, so don't include them unconditionally. rdar://58876107
1 parent 7190073 commit 58bbe1e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/SymbolGraphGen/SymbolGraph.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ void SymbolGraph::recordEdge(const ValueDecl *Source,
139139
}
140140

141141
Nodes.insert(Source);
142-
Nodes.insert(Target);
142+
if (Target->getModuleContext() != &M) {
143+
// Don't claim a symbol just because we have a relationship to it.
144+
// For example, if we conform to `Sequence`, that symbol's node should be
145+
// under Swift, not this module.
146+
Nodes.insert(Target);
147+
}
143148

144149
Edges.insert({this, Kind, Source, Target});
145150
}

test/SymbolGraph/Module/Extension.swift

+6
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ public extension String {
1818
// CHECK: "kind": "memberOf"
1919
// CHECK-NEXT: "source": "s:SS9ExtensionE9somethingSSvp"
2020
// CHECK-NEXT: "target": "s:SS"
21+
22+
// Extending `String` creates a memberOf relationship above.
23+
// However, it should not be included as a node because `String`
24+
// is owned by the Swift module.
25+
// rdar://58876107
26+
// CHECK-NOT: "precise": "s:SS"

0 commit comments

Comments
 (0)