Skip to content

Commit 646546a

Browse files
committed
Added jpath check to ClassLikeSupport getParentsAsTreeSymbolTuples
Fixes scala#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 646546a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package tests
2+
package noJavaParent
3+
4+
// https://github.com/lampepfl/dotty/issues/15927
5+
6+
trait Foo3 extends Numeric[Any]

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

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 NoJavaParent extends SignatureTest("noJavaParent", SignatureTest.all)

0 commit comments

Comments
 (0)