Skip to content

Scaladoc readTasty error with overloads + union parameters #23511

Open
@katrinafyi

Description

@katrinafyi

Compiler version

tested on 3.7.1 and 3.3.4

Minimized code

// remark 6: using an enum instead -> no error
sealed trait E
case object A extends E
case object B extends E
case object C extends E

class Main {
  // remark 1: distinguishing these by @targetName -> no error
  // remark 2: different return types -> still errors
  // remark 3: placing these methods inside an object rather than a class -> no error
  // remark 4: removing an overload -> no error
  // remark 5: removing B.type from the union  -> no error
  def parse(kind: A.type | B.type): Int = 1
  def parse(kind: C.type): Int = 2
}

object Main {
  @main def hello(): Unit =
    val m = Main()
    // remark 7: m.parse(C) -> no error
    // remark 8: m.parse(B) -> still errors
    println(m.parse(A))
}

This can be pasted into a new sbt project (sbt new scala/scala3.g8), then run sbt doc to observe the scaladoc crash (next section).

Also, observe that the code does compile and run without error.

Output

The scaladoc generator reports a fatal error. I can't tell if this error originates from Scaladoc, or if it's caused by an incorrect tasty file.

[info] Main Scala API documentation to /home/x/Downloads/scaladoc-bug/scaladoc-bug/target/scala-3.7.1/api...
[warn] Flag -classpath set repeatedly
[error] -- Error: src/main/scala/Main.scala:20:12 --------------------------------------
[error] 20 |    println(m.parse(A))
[error]    |            ^^^^^^^^^
[error]    |undefined: m.parse # -1: TermRef(TermRef(NoPrefix,val m),parse) at readTasty
[warn] one warning found
[error] one error found
[error] (Compile / doc) DottyDoc Compilation Failed

Expectation

The scaladoc generator should succeed on this valid scala source code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions