Skip to content

Commit 351e9ac

Browse files
committed
fix link resolution regression caused by duplicate feature edges
1 parent 4228c79 commit 351e9ac

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Sources/SymbolGraphCompiler/Extensions/SSGC.Extensions.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ extension SSGC
2424
}
2525
}
2626
extension SSGC.Extensions
27+
{
28+
var all:Dictionary<SSGC.ExtensionSignature, SSGC.ExtensionObject>.Values
29+
{
30+
self.groups.values
31+
}
32+
}
33+
extension SSGC.Extensions
2734
{
2835
mutating
2936
func include(_ vertex:SymbolGraphPart.Vertex,
@@ -114,7 +121,7 @@ extension SSGC.Extensions
114121
/// Gather extension members attributable to the specified culture, simplifying the
115122
/// extension signatures by inspecting the extended declaration. This may coalesce
116123
/// multiple extension objects into a single extension layer.
117-
let coalesced:[SSGC.Extension.ID: SSGC.ExtensionLayer] = try self.groups.values.reduce(
124+
let coalesced:[SSGC.Extension.ID: SSGC.ExtensionLayer] = try self.all.reduce(
118125
into: [:])
119126
{
120127
let blocks:[(id:Symbol.Block, block:SSGC.Extension.Block)] = $1.blocks.reduce(

Sources/SymbolGraphCompiler/SSGC.TypeChecker.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,29 @@ extension SSGC.TypeChecker
525525
""")
526526
}
527527
}
528-
529-
self.resolvableLinks[heir.namespace, heir.value.path, feature.value.path.last].append(
530-
.feature(feature.value, self: heir.id))
531528
}
532529
}
533530
extension SSGC.TypeChecker
534531
{
535-
public __consuming
532+
public consuming
536533
func load(in culture:Symbol.Module) throws -> SSGC.ModuleIndex
537534
{
535+
for `extension`:SSGC.ExtensionObject in self.extensions.all
536+
{
537+
// We add the feature paths here and not in `insert(_:by:)` because those
538+
// edges are frequently duplicated, and it is hard to remove duplicate paths
539+
// after they have been added.
540+
let extendee:SSGC.DeclObject = try self.declarations[`extension`.extendee]
541+
for feature:Symbol.Decl in `extension`.features.keys
542+
{
543+
let feature:SSGC.Decl = try self.declarations[feature].value
544+
let last:String = feature.path.last
545+
546+
self.resolvableLinks[extendee.namespace, extendee.value.path, last].append(
547+
.feature(feature, self: extendee.id))
548+
}
549+
}
550+
538551
let extensions:[SSGC.Extension] = try self.extensions.load(culture: culture,
539552
with: self.declarations)
540553

0 commit comments

Comments
 (0)