Skip to content

Commit 04f5a0b

Browse files
authored
Fix Scaladoc crash when extending non-Scala-3 classes (short-term fix for 3.3.x) (#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 #15927
2 parents e751f51 + 1978bcb commit 04f5a0b

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

Diff for: scaladoc-testcases/src/tests/nonScala3Parent.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package tests
2+
package nonScala3Parent
3+
4+
import javax.swing.JPanel
5+
import javax.swing.JFrame
6+
7+
// https://github.com/lampepfl/dotty/issues/15927
8+
9+
trait Foo1 extends Numeric[Any]
10+
trait Foo2 extends JPanel
11+
trait Foo3 extends JFrame
12+
trait Foo4 extends Ordering[Any]
13+
trait Foo5 extends Enumeration

Diff for: scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,8 @@ trait ClassLikeSupport:
266266
def getParentsAsTreeSymbolTuples: List[(Tree, Symbol)] =
267267
if noPosClassDefs.contains(c.symbol) then Nil
268268
else for
269-
parentTree <- c.parents if parentTree.pos.start != parentTree.pos.end // We assume here that order is correct
269+
// TODO: add exists function to position methods in Quotes and replace the condition here for checking the JPath
270+
parentTree <- c.parents if parentTree.pos.sourceFile.getJPath.isDefined && parentTree.pos.start != parentTree.pos.end // We assume here that order is correct
270271
parentSymbol = parentTree match
271272
case t: TypeTree => t.tpe.typeSymbol
272273
case tree if tree.symbol.isClassConstructor => tree.symbol.owner

Diff for: scaladoc/test/dotty/tools/scaladoc/signatures/TranslatableSignaturesTestCases.scala

+2
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,5 @@ class ImplicitMembers extends SignatureTest(
106106
Seq("def"),
107107
filterFunc = _.toString.endsWith("OuterClass$ImplicitMemberTarget.html")
108108
)
109+
110+
class NonScala3Parent extends SignatureTest("nonScala3Parent", SignatureTest.all)

0 commit comments

Comments
 (0)