Skip to content

Commit bd0858e

Browse files
authored
Scaladoc: fix crash when processing extends call (scala#17260)
Fixes scala#17234
2 parents c8afe26 + fe4478b commit bd0858e

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package tests
2+
package extendsCall
3+
4+
class Impl() extends Base(Seq.empty, c = "-") //expected: class Impl() extends Base
5+
6+
class Base(val a: Seq[String], val b: String = "", val c: String = "") //expected: class Base(val a: Seq[String], val b: String, val c: String)

scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@ trait ClassLikeSupport:
6464
signatureOnly: Boolean = false,
6565
modifiers: Seq[Modifier] = classDef.symbol.getExtraModifiers(),
6666
): Member =
67-
def unpackTreeToClassDef(tree: Tree): ClassDef = tree match
68-
case tree: ClassDef => tree
69-
case TypeDef(_, tbt: TypeBoundsTree) => unpackTreeToClassDef(tbt.tpe.typeSymbol.tree)
70-
case TypeDef(_, tt: TypeTree) => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)
71-
case c: Apply =>
72-
c.symbol.owner.tree.symbol.tree match
67+
def unpackTreeToClassDef(tree: Tree): ClassDef =
68+
def unpackApply(a: Apply) =
69+
a.symbol.owner.tree match
7370
case tree: ClassDef => tree
74-
case tt: TypeTree => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)
71+
72+
tree match
73+
case tree: ClassDef => tree
74+
case TypeDef(_, tbt: TypeBoundsTree) => unpackTreeToClassDef(tbt.tpe.typeSymbol.tree)
75+
case TypeDef(_, tt: TypeTree) => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)
76+
case c: Apply => unpackApply(c)
77+
case Block(_, c: Apply) => unpackApply(c)
78+
case tt: TypeTree => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)
7579

7680
def signatureWithName(s: dotty.tools.scaladoc.Signature): dotty.tools.scaladoc.Signature =
7781
s match

scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,5 @@ class ImplicitMembers extends SignatureTest(
108108
)
109109

110110
class NonScala3Parent extends SignatureTest("nonScala3Parent", SignatureTest.all)
111+
112+
class ExtendsCall extends SignatureTest("extendsCall", SignatureTest.all)

0 commit comments

Comments
 (0)