scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

FieldMirror.set should allow setting vals #7464

Closed scabug closed 11 years ago

scabug commented 11 years ago

Currently it says something like this:

[info] - main *** FAILED ***
[info]   scala.ScalaReflectionException: cannot set an immutable field x
[info]   at scala.reflect.runtime.JavaMirrors$JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$ErrorSetImmutableField(JavaMirrors.scala:136)
[info]   at scala.reflect.runtime.JavaMirrors$JavaMirror$JavaFieldMirror.set(JavaMirrors.scala:285)
[info]   at scala.pickling.InterpretedUnpicklerRuntime$$anon$2$$anonfun$unpickle$1.apply(Runtime.scala:135)
[info]   at scala.pickling.InterpretedUnpicklerRuntime$$anon$2$$anonfun$unpickle$1.apply(Runtime.scala:132)
[info]   at scala.collection.immutable.List.foreach(List.scala:318)
[info]   at scala.pickling.InterpretedUnpicklerRuntime$$anon$2.unpickle(Runtime.scala:132)
[info]   at scala.pickling.singleton.hierarchy.SingletonHierarchyTest$$anonfun$1.test$1(singleton-hierarchy.scala:17)
[info]   at scala.pickling.singleton.hierarchy.SingletonHierarchyTest$$anonfun$1.apply$mcV$sp(singleton-hierarchy.scala:19)
[info]   at scala.pickling.singleton.hierarchy.SingletonHierarchyTest$$anonfun$1.apply(singleton-hierarchy.scala:12)
[info]   at scala.pickling.singleton.hierarchy.SingletonHierarchyTest$$anonfun$1.apply(singleton-hierarchy.scala:12)

At first setting up that sentinel seemed like a good idea, but on a second thought this only brings annoyance. After all, that's reflection, a tool designed to circumvent all rules.

scabug commented 11 years ago

Imported From: https://issues.scala-lang.org/browse/SI-7464?orig=1 Reporter: @xeno-by Affected Versions: 2.10.0, 2.10.1

scabug commented 11 years ago

@xeno-by said: https://github.com/scala/scala/pull/2504