Skip to content

Commit

Permalink
Fix Scaladoc crash when extending non-Scala-3 classes (short-term fix…
Browse files Browse the repository at this point in the history
… for 3.3.x) (scala#16759)

Added jpath check to `ClassLikeSupport` getParentsAsTreeSymbolTuples
— check for whether the non-scala3 parent exists before checking the
start and end of the span to confirm whether the span exists in
getParentsAsTreeSymbolTuples.

Fixes scala#15927
  • Loading branch information
Kordyjan authored Feb 2, 2023
2 parents e751f51 + 1978bcb commit 04f5a0b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions scaladoc-testcases/src/tests/nonScala3Parent.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package tests
package nonScala3Parent

import javax.swing.JPanel
import javax.swing.JFrame

// https://github.com/lampepfl/dotty/issues/15927

trait Foo1 extends Numeric[Any]
trait Foo2 extends JPanel
trait Foo3 extends JFrame
trait Foo4 extends Ordering[Any]
trait Foo5 extends Enumeration
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ trait ClassLikeSupport:
def getParentsAsTreeSymbolTuples: List[(Tree, Symbol)] =
if noPosClassDefs.contains(c.symbol) then Nil
else for
parentTree <- c.parents if parentTree.pos.start != parentTree.pos.end // We assume here that order is correct
// TODO: add exists function to position methods in Quotes and replace the condition here for checking the JPath
parentTree <- c.parents if parentTree.pos.sourceFile.getJPath.isDefined && parentTree.pos.start != parentTree.pos.end // We assume here that order is correct
parentSymbol = parentTree match
case t: TypeTree => t.tpe.typeSymbol
case tree if tree.symbol.isClassConstructor => tree.symbol.owner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,5 @@ class ImplicitMembers extends SignatureTest(
Seq("def"),
filterFunc = _.toString.endsWith("OuterClass$ImplicitMemberTarget.html")
)

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

0 comments on commit 04f5a0b

Please sign in to comment.