Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant Expressions not allowed as ClassfileAnnotation annotation arguments: Array(""); constant value definition containing class, or Array #3183

Closed
scabug opened this issue Mar 15, 2010 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 15, 2010

I would expect all of these to compile.

class T(value: Any) extends ClassfileAnnotation
 
object Holder {
   final val as = Array(1, 2, 3)
   final val a = 1
   final val cint = classOf[Int]
}

import Holder._
 
@T(classOf[Int])
@T(cint) // error: annotation argument needs to be a constant; found: cint
@T(Array("", "", "")) // error: annotation argument needs to be a constant; found: as
@T(as) // error: annotation argument needs to be a constant; found: as
@T(1)
@T(a)
class Target

Tested with 2.8.0.Beta1 and 2.8.0.r21166-b20100315020141.

@scabug
Copy link
Author

scabug commented Mar 15, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3183?orig=1
Reporter: @retronym

@scabug
Copy link
Author

scabug commented Mar 31, 2010

@lrytz said:
(In r21309) close #3183. review by community

@scabug
Copy link
Author

scabug commented Mar 31, 2010

@lrytz said:
note that the a reference to an array stored in a final field is still not valid.

the reason is that the scala compiler cannot represent array literals as constants internally, changing this would be more involved and extend the scope of a ticket fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants