Skip to content

Commit 3fc0c68

Browse files
authored
Resolves error in prior logic (#102)
Overlay imports don't accurately describe the graph name they're modifying _in_ the graph, so when ever we have bystanders, we need to use the parsing of the URL name for the relevant module being extended. This PR updates the prior logic and fixes the test that incorrectly asserting that [email protected] were symbols that extended the "A" module, when the extend the "B" module.
1 parent 1990702 commit 3fc0c68

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Sources/SymbolKit/UnifiedSymbolGraph/GraphCollector.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ extension GraphCollector {
139139
let isMainSymbolGraph = !url.lastPathComponent.contains("@") && !graph.module.isVirtual
140140

141141
let moduleName: String
142-
if isMainSymbolGraph || graph.module.bystanders != nil {
142+
if isMainSymbolGraph && graph.module.bystanders == nil {
143143
// When bystander modules are present, the symbol graph is a cross-import overlay, and
144144
// we need to preserve the original module name to properly render it. It is still
145145
// kept with the extension symbols, due to the merging behavior of UnifiedSymbolGraph.
@@ -165,6 +165,9 @@ extension GraphCollector {
165165
// of the module that was extended (rdar://63200368).
166166
let fileName = url.lastPathComponent.components(separatedBy: ".symbols.json")[0]
167167

168+
// Overlay imports of the form `[email protected]` have the graph name being "A", but are symbols
169+
// that apply to the "B" module, which isn't included in the graph - so we have to drop back to parsing
170+
// the module name from the name of the symbolgraph.
168171
let fileNameComponents = fileName.components(separatedBy: "@")
169172
if fileNameComponents.count > 2 {
170173
// For a while, cross-import overlay symbol graphs had more than two components:

Tests/SymbolKitTests/UnifiedGraph/GraphCollectorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,6 @@ class GraphCollectorTests: XCTestCase {
185185

186186
let (extendedB, extendedBIsMain) = GraphCollector.moduleNameFor(a_At_B, at: .init(fileURLWithPath: "[email protected]"))
187187
XCTAssertFalse(extendedBIsMain)
188-
XCTAssertEqual("A", extendedB)
188+
XCTAssertEqual("B", extendedB)
189189
}
190190
}

0 commit comments

Comments
 (0)