Closed
Description
@volatile
annotation only makes sense on variables. The compiler should not allow to use this annotation on immutable val
field.
Compiler version
All Scala 3 versions
Minimized code
class Foo:
@volatile val x: Int = ???
Output
No warnings
Expectation
Give the same error as Scala 2:
./main.scala:2: error: values cannot be volatile
@volatile val x: Int = ???
^