Open
Description
Apropos of scala/scala#5892:
Timed.java
:
package a;
public @interface Timed {
public static final long ONE_DAY = 1000 * 60 * 60 * 24;
/* millis */
long value();
}
Test.scala
:
package a
@Timed(value = Timed.ONE_DAY)
object Main
yields:
[error] /Users/hhoughton/temp/Test.scala:3: annotation argument needs to be a constant; found: Timed.ONE_DAY
[error] @Timed(value = Timed.ONE_DAY)
[error] ^
If Timed.java
is compiled first, this works fine.
This is because varDecl
in JavaParsers
only gives a static final
constant a ConstantType
d tree if its rhs is a literal. To fix this, tryLiteral
will need swapped out for something a bit more sophisticated (plausibly ConditionalExpression
in the java grammar).
I've got work done on this already; filing this ticket so I can justify PRing it separately from the linked annotation pr.