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
```
cat sandbox/test1.scala && javap -c -classpath . T C
trait T {
def m = 42
}
class C extends T
object Test {
def main(args: Array[String]): Unit = {
val c = new C()
assert(c.m == 42)
}
}
Compiled from "test1.scala"
public interface T {
public int m();
Code:
0: bipush 42
2: ireturn
public void $init$();
Code:
0: return
}
Compiled from "test1.scala"
public class C implements T {
public int m();
Code:
0: aload_0
1: invokespecial #14 // Method T.m:()I
4: ireturn
public C();
Code:
0: aload_0
1: invokespecial #20 // Method java/lang/Object."<init>":()V
4: aload_0
5: invokespecial #23 // Method T.$init$:()V
8: return
}
```
Here's another test that shows private methods working:
```
cat sandbox/test3.scala && qscalac sandbox/test3.scala && javap -private -classpath . -c T C && qscala Test
trait T {
private def foo = 0
def bar = foo
}
class C extends T
object Test {
def main(args: Array[String]): Unit = {
new C().bar
}
}
Compiled from "test3.scala"
public interface T {
private int foo();
Code:
0: iconst_0
1: ireturn
public int bar();
Code:
0: aload_0
1: invokespecial #15 // Method foo:()I
4: ireturn
public void $init$();
Code:
0: return
}
Compiled from "test3.scala"
public class C implements T {
public int bar();
Code:
0: aload_0
1: invokespecial #14 // Method T.bar:()I
4: ireturn
public C();
Code:
0: aload_0
1: invokespecial #20 // Method java/lang/Object."<init>":()V
4: aload_0
5: invokespecial #23 // Method T.$init$:()V
8: return
}
```
/** Return a map of single-use fields to the lazy value that uses them during initialization.
424
376
* Each field has to be private and defined in the enclosing class, and there must
@@ -1108,7 +1060,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
1108
1060
valrhs=
1109
1061
enteringPickler(sym.info) match {
1110
1062
casect: ConstantType=> gen.mkAttributedQualifier(ct) // don't call forwarder if it's just going to return a literal (no need for this in the new trait encoding)
1111
-
case _ =>Apply(staticRef(sym.alias), gen.mkAttributedThis(clazz) :: sym.paramss.head.map(Ident))
1063
+
case _ =>Apply(Select(Super(clazz, tpnme.EMPTY), sym.alias), sym.paramss.head.map(Ident))
0 commit comments