Skip to content

Commit 60747c3

Browse files
committed
Added jpath check to ClassLikeSupport getParentsAsTreeSymbolTuples
Fixes #15927 Check for whether the java parent exists before checking the start and end of the span to confirm whether the span exists in getParentsAsTreeSymbolTuples.
1 parent eeb00d4 commit 60747c3

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed
Lines changed: 13 additions & 0 deletions
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

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

Lines changed: 2 additions & 1 deletion
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

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

Lines changed: 2 additions & 0 deletions
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)