twitter/rsc

Scalasig and bytecode differences in 2.12.8 when compiling final objects

wiwa opened this issue · 0 comments

wiwa commented

A.scala:

final object A
   name: "A"
   source: "A.scala"
   symbols {
     tag: MODULEsym
     id: <empty>.#A.
-    flags: FINAL | MODULE
+    flags: MODULE
     info {
       tag: TYPEREFtpe
       pre {
         tag: THIStpe
         sym: <empty>.#
@@ -15,11 +15,11 @@
     }
   }
   symbols {
     tag: CLASSsym
     id: <empty>.#A.#
-    flags: FINAL | MODULE
+    flags: MODULE
     info {
       tag: CLASSINFOtpe
       sym: <empty>.#A.#
       parents {
         tag: TYPEREFtpe

Bytecode differences will happen when this final object is in another object, regardless of the outer object's finality. There may be other cases too...

X.scala:

object X {
  final object A
}

Y.scala:

class Y {
  def foo = X.A
}
diff --git a/Y.class.asm b/Y.class.asm
index 87af470..7210c82 100644
--- a/Y.class.asm
+++ b/Y.class.asm
@@ -2,8 +2,8 @@
 // access flags 0x21
 public class Y {
 
-  // access flags 0x19
-  public final static INNERCLASS X$A$ X A$
+  // access flags 0x9
+  public static INNERCLASS X$A$ X A$
 
   // access flags 0x1
   public <init>()V