Skip to content

Scaladoc incorrectly fails on some constants it thinks are unused #12303

@NthPortal

Description

@NthPortal

reproduction steps

using Scala 2.13.x, [2.12.2, 2.12.12],

File Test.scala:

import scala.annotation.implicitNotFound

object Test {
  private final val one   = "foo"
  private final val two   = "foo" + "bar"
  private final val three = "foo" + "bar" + "baz"
  private final val four  = "foo" + "bar" + "baz" + " oh no"

  @implicitNotFound(one)   trait One
  @implicitNotFound(two)   trait Two
  @implicitNotFound(three) trait Three
  @implicitNotFound(four)  trait Four
}

For 2.13:

$ scaladoc -Xlint -Werror Test.scala
Test.scala:6: warning: private val three in object Test is never used
  private final val three = "foo" + "bar" + "baz"
                    ^
Test.scala:7: warning: private val four in object Test is never used
  private final val four  = "foo" + "bar" + "baz" + " oh no"
                    ^
error: No warnings can be incurred under -Werror.
2 warnings

For 2.12.2 through 2.12.12:

$ scaladoc -Xlint -Xfatal-warnings Test.scala
Test.scala:6: warning: private val three in object Test is never used
  private final val three = "foo" + "bar" + "baz"
                    ^
Test.scala:7: warning: private val four in object Test is never used
  private final val four  = "foo" + "bar" + "baz" + " oh no"
                    ^
error: No warnings can be incurred under -Xfatal-warnings.
model contains 6 documentable templates
two warnings found
one error found

problem

  • the values are used
  • it only happens when the constant is defined by more than one string concatenation
  • it's checked by scaladoc at all, when it really shouldn't be

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions