Skip to content

scoverage reports annotations must be constant when they are already final vals #45

@robconrad

Description

@robconrad

Scalac is able to compile annotations that are specified as final vals because those are acually constant (unlike a val or anything else). For example, this compiles:

object Foo {
  final val foo = 1L
}

@SerialVersionUID(value = Foo.foo)
class Bar

However, running scoverage:test on the above generates:

$ ./sbt scoverage:test 
[info] Loading project definition from ~/project
[info] Set current project to example 
[info] Compiling 2 Scala sources to ~/project/target/scala-2.11/scoverage-classes...
[scoverage]: Begin pre-instrumentation phase
[scoverage]: Pre-instrumentation complete
[error] ~/project/src/main/scala/com/coinposit/Foo.scala:7: annotation argument needs to be a constant; found: Foo.foo
[error] @SerialVersionUID(value = Foo.foo)
[error] 1 errors found
[error] (project/scoverage:compile) Compilation failed

Shouldn't scoverage be able to understand final vals as constant in annotations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions