Skip to content

Commit

Permalink
scaladoc: fix crash when processing extends call
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian3k committed Apr 16, 2023
1 parent 2f4cc4c commit 0d2ffb5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
6 changes: 6 additions & 0 deletions scaladoc-testcases/src/tests/extendsCall.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package tests
package extendsCall

class Impl() extends Base(Seq.empty, c = "-") //expected: class Impl() extends Base

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)
18 changes: 11 additions & 7 deletions scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ trait ClassLikeSupport:
signatureOnly: Boolean = false,
modifiers: Seq[Modifier] = classDef.symbol.getExtraModifiers(),
): Member =
def unpackTreeToClassDef(tree: Tree): ClassDef = tree match
case tree: ClassDef => tree
case TypeDef(_, tbt: TypeBoundsTree) => unpackTreeToClassDef(tbt.tpe.typeSymbol.tree)
case TypeDef(_, tt: TypeTree) => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)
case c: Apply =>
c.symbol.owner.tree.symbol.tree match
def unpackTreeToClassDef(tree: Tree): ClassDef =
def unpackApply(a: Apply) =
a.symbol.owner.tree.symbol.tree match
case tree: ClassDef => tree
case tt: TypeTree => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)

tree match
case tree: ClassDef => tree
case TypeDef(_, tbt: TypeBoundsTree) => unpackTreeToClassDef(tbt.tpe.typeSymbol.tree)
case TypeDef(_, tt: TypeTree) => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)
case c: Apply => unpackApply(c)
case Block(_, c: Apply) => unpackApply(c)
case tt: TypeTree => unpackTreeToClassDef(tt.tpe.typeSymbol.tree)

def signatureWithName(s: dotty.tools.scaladoc.Signature): dotty.tools.scaladoc.Signature =
s match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,5 @@ class ImplicitMembers extends SignatureTest(
)

class NonScala3Parent extends SignatureTest("nonScala3Parent", SignatureTest.all)

class ExtendsCall extends SignatureTest("extendsCall", SignatureTest.all)

0 comments on commit 0d2ffb5

Please sign in to comment.