Closed
Description
Compiler version
3.1.0 and 3.1.1
Minimized code
class Test() {
@transient lazy val lazyVal = "lazy"
@transient val ordinaryVal = "ordinary"
}
Output
javap generates:-
public static final long OFFSET$0;
descriptor: J
flags: (0x0019) ACC_PUBLIC, ACC_STATIC, ACC_FINAL
public long 0bitmap$1;
descriptor: J
flags: (0x0001) ACC_PUBLIC
public java.lang.String lazyVal$lzy1;
descriptor: Ljava/lang/String;
flags: (0x0001) ACC_PUBLIC
private final transient java.lang.String ordinaryVal;
descriptor: Ljava/lang/String;
flags: (0x0092) ACC_PRIVATE, ACC_FINAL, ACC_TRANSIENT
Expectation
0bitmap$1 and lazyVal$lzy1 should both have flag ACC_TRANSIENT.
I am also confused when reading SIP-20 (version 6) as to what OFFSET$0 does - it does not appear in https://dotty.epfl.ch/docs/reference/changed-features/lazy-vals-init.html equivalent code (how could it, an ACC_STATIC can not be directly be directly created in Scala). But it does appear in the code produced by 3.1.0 and 3.1.1. Being ACC_STATIC it can not also be ACC_TRANSIENT, but I am unsure whether the code as currently implemented would survive serialisation or any equivalent code following the same rules for what get processed.