Skip to content

Commit 6bfe99b

Browse files
authored
Backport "Fix #17577: scaladoc hangs with deep inheritance" to LTS (#18991)
Backports #17954 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents bac11d4 + d3266d8 commit 6bfe99b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

scaladoc/src/dotty/tools/scaladoc/api.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ case class LinkToType(signature: Signature, dri: DRI, kind: Kind)
145145
case class HierarchyGraph(edges: Seq[(LinkToType, LinkToType)], sealedNodes: Set[LinkToType] = Set.empty):
146146
def vertecies: Seq[LinkToType] = edges.flatten((a, b) => Seq(a, b)).distinct
147147
def verteciesWithId: Map[LinkToType, Int] = vertecies.zipWithIndex.toMap
148-
def +(edge: (LinkToType, LinkToType)): HierarchyGraph = HierarchyGraph((edges :+ edge).distinct)
149-
def ++(edges: Seq[(LinkToType, LinkToType)]): HierarchyGraph = edges.foldLeft(this) {
150-
case (acc, edge) => acc + edge
151-
}
148+
def +(edge: (LinkToType, LinkToType)): HierarchyGraph = this ++ Seq(edge)
149+
def ++(edges: Seq[(LinkToType, LinkToType)]): HierarchyGraph =
150+
this.copy(edges = this.edges.view.concat(edges).distinct.toSeq)
151+
152152
object HierarchyGraph:
153153
def empty = HierarchyGraph(Seq.empty)
154154
def withEdges(edges: Seq[(LinkToType, LinkToType)]) = HierarchyGraph.empty ++ edges

scaladoc/src/dotty/tools/scaladoc/transformers/InheritanceInformationTransformer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package transformers
33

44
class InheritanceInformationTransformer(using DocContext) extends (Module => Module):
55
override def apply(original: Module): Module =
6-
val subtypes = getSupertypes(original.rootPackage).groupMap(_(0))(_(1))
6+
val subtypes = getSupertypes(original.rootPackage).groupMap(_(0))(_(1)).view.mapValues(_.distinct).toMap
77
original.updateMembers { m =>
88
val edges = getEdges(m.asLink.copy(kind = bareClasslikeKind(m.kind)), subtypes)
99
val st: Seq[LinkToType] = edges.map(_._1).distinct
10-
m.withKnownChildren(st).withNewGraphEdges(edges)
10+
m.withKnownChildren(st).withNewGraphEdges(edges.toSeq)
1111
}
1212

1313
private def getEdges(ltt: LinkToType, subtypes: Map[DRI, Seq[LinkToType]]): Seq[(LinkToType, LinkToType)] =
14-
val st: Seq[LinkToType] = subtypes.getOrElse(ltt.dri, Nil)
15-
st.flatMap(s => Seq(s -> ltt) ++ getEdges(s, subtypes))
14+
val st: Seq[LinkToType] = subtypes.getOrElse(ltt.dri, Vector.empty)
15+
st.flatMap(s => Vector(s -> ltt) ++ getEdges(s, subtypes))
1616

1717
private def bareClasslikeKind(kind: Kind): Kind = kind match
1818
case _: Kind.Trait => Kind.Trait(Nil, Nil)

0 commit comments

Comments
 (0)