Skip to content

Scaladoc: fix crash when processing extends call #17260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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)