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
java.lang.IllegalAccessError: Update to non-static final field Test$$anon$1.foo attempted from a different method (T$_setter_$foo_$eq) than the initializer method <init>
typedApply of synchronized(...) -> inferMethodInstance -> TreeTypeSubstituter for type parameter of synchronized
TypeMapTreeSubstituter (parent of TreeTypeSubstituter) calls if (tree.isDef) tree.symbol modifyInfo typeMap
modifyInfo on the anonymous class symbol is destructive for the type history:
=> setInfo(f(info)) takes the current info and creates a new TypeHistory with just one element
=> the type history has the entry fields -> ClassInfoType(...) (the type itself is unchanged)
When obtaining the anonymous class info in a later phase, the fields info transformer will run again because the current type is only valid until fields. A new foo field symbol is created, it doesn't have the MUTABLE flag, so it ends up final in bytecode.
Uncovered by akka/akka#32128 when dropping JDK 8 in Akka (akka/akka#32127).
Additional case for scala/scala-dev#408 and #12340.
Trait fields are still marked final when implemented by an anonymous class in a lazy val.
Reproduction steps
Problem
Field marked final:
When it's either not a lazy val or not an anonymous class, the field is non-final:
The text was updated successfully, but these errors were encountered: