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

@volatile var cannot be defined in case class with confusing error message #8873

Closed
scabug opened this issue Oct 1, 2014 · 4 comments
Closed

Comments

@scabug
Copy link

scabug commented Oct 1, 2014

scala> case class X(@volatile var x:Int)
<console>:7: error: values cannot be volatile
       case class X(@volatile var x:Int)
                                  ^

// where compiler see values ?

@scabug
Copy link
Author

scabug commented Oct 1, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8873?orig=1
Reporter: ruslan shevchenko (rssh)
Affected Versions: 2.11.2
Duplicates #8826

@scabug
Copy link
Author

scabug commented Oct 2, 2014

@gourlaysama said:
Hmm, that's a bug in case class synthetic methods. The compiler wrongly keeps the @volative annotation in the generated apply constructor:

object X extends AbstractFunction1[Int,X] with Serializable {
...
def apply(@volatile x: Int): X = new X(x) // that's wrong
}

@scabug
Copy link
Author

scabug commented Nov 4, 2014

@retronym said:
Reassinging to 2.11.5, 2.11.4 has already been released.

@scabug
Copy link
Author

scabug commented Aug 12, 2016

@adriaanm said:
picked this one up in scala/scala#5294

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

No branches or pull requests

2 participants