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 comment for multiple enum cases is silently ignored without any warning #16610

Closed unkarjedy closed 6 months ago

unkarjedy commented 1 year ago

Compiler version

ThisBuild / version := "0.1.0-SNAPSHOT"

ThisBuild / scalaVersion := "3.2.1"

lazy val root = (project in file("."))
  .settings(
    name := "untitled380"
  )

Minimized code

/**
 * Description of enum
 */
enum MyEnum {

  /**
   * Description of case 1
   */
  case MyCase1

  /**
   * Description of case 1 and 3
   */
  case MyCase2, MyCase3
}

Run sbt doc Notice that no documentation will be generated for MyCase2 and MyCase3:

This is kinda expected (to some degree), for example because scala doc could contain references to parameters and type parameters:

/**
 * @param myParameter parameter description
 * @tparam MyTypeParameter type parameter description
 *
 */
enum TestEnum[MyTypeParameter](myParameter: Int) {
  /**
   * @param myParameterInner42 parameter description
   * @tparam MyTypeParameterInner type parameter description
   */
  case EnumMember[MyTypeParameterInner](myParameterInner42: Int)
    extends TestEnum[MyTypeParameterInner](myParameterInner42)
}

Expectation

At least some warning should be printed during sbt doc. Something like "Scaladoc at position ... was ignored because..."

Actual result

The comment is silently ignored without any warning

unkarjedy commented 1 year ago

Noticed while fixing https://youtrack.jetbrains.com/issue/SCL-20892

Dedelweiss commented 1 year ago

Hello @unkarjedy, during my research on your problem, with @ckipp01, we noticed that the comment deletion as in your example was not done during the generation of Scaladoc but well before.

As you can see in the screenshot below, the comment is not already present in the TASTY file of our code. So when our scaladoc is generated with "sbt doc" for example, it already has no idea of the existence of this comment, which makes the warning at scaladoc generation time impossible.

One of the secondary solutions would be to send a warning when the comment is deleted at compile time, but this is no longer relevant to the generation of the scaladoc.

Screenshot 2023-03-17 at 13 58 06