Skip to content
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

Fix Scaladoc crash when extending non-Scala-3 classes (long-term fix for 3.4.0) #16761

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler

given PositionMethods: PositionMethods with
extension (self: Position)
def exists: Boolean = self.exists
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be an extension export ?

def start: Int = self.start
def end: Int = self.end
def sourceFile: SourceFile = self.source
Expand Down
2 changes: 2 additions & 0 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4499,6 +4499,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** Extension methods of `Position` */
trait PositionMethods {
extension (self: Position)
/** Whether we have Span information at all */
def exists: Boolean

/** The start offset in the source file */
def start: Int
Expand Down
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,7 @@ 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
parentTree <- c.parents if parentTree.pos.exists && 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)