You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Annotations like @transient and @volatile are not correctly applied to private[this] fields inside traits. This can easily lead to incorrect behavior (I was surprised to find my program broke when I changed a @transient var in a trait from private to private[this].)
traitFoo {
@transient private[this] vara:String=""// not transient!!@transient privatevarb:String=""@transient varc:String=""@transient private[this] vald:String=""// not transient!!@transient privatevale:String=""@transient valf:String=""@volatile private[this] varx:String=""// not volatile!! @volatile privatevary:String=""@volatile varz:String=""
}
classBarextendsFoo
The text was updated successfully, but these errors were encountered:
Jeff Olson (jdolson) said:
If the fix is non-trivial, it would at least be nice to have a warning that your annotation will get ignored in such cases with the suggestion to change the field from private[this] to private.
@retronym said:
See also #7954, in which the @Strictfp annotations is dropped on the floor as code is moved around in our encoding of traits and value classes.
Jeff Olson (jdolson) said:
What makes this extra fun, is that the workaround of replacing private[this] with private may not do any good. This is because sbt won't necessarily recompile classes implementing the trait because it doesn't think the public interface of the trait has changed.
So be sure and do a clean compile if you apply this workaround.
Annotations like
@transient
and@volatile
are not correctly applied toprivate[this]
fields inside traits. This can easily lead to incorrect behavior (I was surprised to find my program broke when I changed a@transient var
in a trait fromprivate
toprivate[this]
.)The text was updated successfully, but these errors were encountered: