Suppose I have the following file test.scala
import scala.language.postfixOps
trait Trait {
var v = 'a
def update(x :Symbol):Unit = {
v = x
}
}
object x extends Trait
x update 'b
// value of x.v is now 'b, as expected
object y extends Trait {
update('c)
}
// value of y.v is now 'c, as expected
object z extends Trait {
// this causes compilation failure:
update 'd
}
When I run the above code, the postfix invocation inside the object z init block fails:
$ scala test.scala
test.scala:23: error: ';' expected but symbol literal found.
update 'd
I haven't had any luck trying to find an explaination for why scala fails to understand the postfix inside the object init block, or what (if anything) can be done to make it work.