scala / scala3

The Scala 3 compiler, also known as Dotty.
https://dotty.epfl.ch
Apache License 2.0
5.81k stars 1.05k forks source link

Scaladoc regression, when using java defined annotations #18231

Open WojciechMazur opened 1 year ago

WojciechMazur commented 1 year ago

Based on OpenCB failure in akka/akka-http https://github.com/VirtusLab/community-build3/actions/runs/5557868276/jobs/10152257798

Compiler version

3.3.2-RC Works in 3.3.1-RC4

Bisect results: Last good release: 3.3.2-RC1-bin-20230615-916d4e7-NIGHTLY First bad release: 3.3.2-RC1-bin-20230619-a68568c-NIGHTLY

The commit-based bisect fails due to an errors when publishing compiler

Minimized code

Fails only when compiling with scaladoc, compiles correctly in standard compilation

//> using option -release:8

object Foo {
    @Deprecated
    def foo(): Unit = ???
}

Output

-- Error: main.scala:4:4 -------------------------------------------------------
4 |    @Deprecated
  |    ^^^^^^^^^^^
  |wrong number of arguments at <no phase> for (since: String, forRemoval: Boolean): Deprecated: (Deprecated#<init> : (since: String, forRemoval: Boolean): Deprecated), expected: 2, found: 0
1 error found

Expectation

Should compile

Florian3k commented 1 year ago

This works fine using java 8 (scala-cli doc i18231.scala --jvm 8) but fails with newer (scala-cli doc i18231.scala --jvm 11)

Deprecated annotation contains 2 new fields since java 9 (since and forRemoval, see java docs)

Source for this error (wrong number of arguments at ...) is in the compiler, not scaladoc, so it's coming from the TastyInspector most likely. I suspect there is some problem with classpath that TastyInspector is using, but I don't know much about TASTy and TastyInspector. In the range of commits from bisect the only one that looks suspicious to me is https://github.com/lampepfl/dotty/commit/3b20d785825747621c0500a2e92f55eb02f8cd55

Florian3k commented 6 months ago

Underlying issue is most likely this: https://github.com/scala/scala3/issues/19951