Last active
August 29, 2015 14:02
-
-
Save non/10b90fd31f8d4d549f56 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test | |
trait Ugh | |
class Test { | |
def ugh = new Ugh { | |
def blah: Int = 999 | |
} | |
} | |
class Main { | |
def foo: Int = (new Test).ugh.blah | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//scalac -Xprint:typer test.scala | |
[[syntax trees at end of typer]] // test.scala | |
package test { | |
abstract trait Ugh extends scala.AnyRef; | |
class Test extends scala.AnyRef { | |
def <init>(): test.Test = { | |
Test.super.<init>(); | |
() | |
}; | |
def ugh: test.Ugh{def blah: Int} = { | |
final class $anon extends AnyRef with test.Ugh { | |
def <init>(): anonymous class $anon = { | |
$anon.super.<init>(); | |
() | |
}; | |
def blah: Int = 999 | |
}; | |
new $anon() | |
} | |
}; | |
class Main extends scala.AnyRef { | |
def <init>(): test.Main = { | |
Main.super.<init>(); | |
() | |
}; | |
def foo: Int = new Test().ugh.blah | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//javap -c -private test.Main | |
Compiled from "test.scala" | |
public class test.Main { | |
private static java.lang.Class[] reflParams$Cache1; | |
private static volatile java.lang.ref.SoftReference reflPoly$Cache1; | |
public static {}; | |
Code: | |
0: iconst_0 | |
1: anewarray #12 // class java/lang/Class | |
4: putstatic #16 // Field reflParams$Cache1:[Ljava/lang/Class; | |
7: new #18 // class java/lang/ref/SoftReference | |
10: dup | |
11: new #20 // class scala/runtime/EmptyMethodCache | |
14: dup | |
15: invokespecial #23 // Method scala/runtime/EmptyMethodCache."<init>":()V | |
18: invokespecial #26 // Method java/lang/ref/SoftReference."<init>":(Ljava/lang/Object;)V | |
21: putstatic #30 // Field reflPoly$Cache1:Ljava/lang/ref/SoftReference; | |
24: return | |
public static java.lang.reflect.Method reflMethod$Method1(java.lang.Class); | |
Code: | |
0: getstatic #30 // Field reflPoly$Cache1:Ljava/lang/ref/SoftReference; | |
3: invokevirtual #36 // Method java/lang/ref/SoftReference.get:()Ljava/lang/Object; | |
6: checkcast #38 // class scala/runtime/MethodCache | |
9: astore_1 | |
10: aload_1 | |
11: ifnonnull 33 | |
14: new #20 // class scala/runtime/EmptyMethodCache | |
17: dup | |
18: invokespecial #23 // Method scala/runtime/EmptyMethodCache."<init>":()V | |
21: astore_1 | |
22: new #18 // class java/lang/ref/SoftReference | |
25: dup | |
26: aload_1 | |
27: invokespecial #26 // Method java/lang/ref/SoftReference."<init>":(Ljava/lang/Object;)V | |
30: putstatic #30 // Field reflPoly$Cache1:Ljava/lang/ref/SoftReference; | |
33: aload_1 | |
34: aload_0 | |
35: invokevirtual #41 // Method scala/runtime/MethodCache.find:(Ljava/lang/Class;)Ljava/lang/reflect/Method; | |
38: astore_2 | |
39: aload_2 | |
40: ifnull 45 | |
43: aload_2 | |
44: areturn | |
45: getstatic #47 // Field scala/runtime/ScalaRunTime$.MODULE$:Lscala/runtime/ScalaRunTime$; | |
48: aload_0 | |
49: ldc #49 // String blah | |
51: getstatic #16 // Field reflParams$Cache1:[Ljava/lang/Class; | |
54: invokevirtual #53 // Method java/lang/Class.getMethod:(Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method; | |
57: invokevirtual #57 // Method scala/runtime/ScalaRunTime$.ensureAccessible:(Ljava/lang/reflect/Method;)Ljava/lang/reflect/Method; | |
60: astore_2 | |
61: new #18 // class java/lang/ref/SoftReference | |
64: dup | |
65: aload_1 | |
66: aload_0 | |
67: aload_2 | |
68: invokevirtual #61 // Method scala/runtime/MethodCache.add:(Ljava/lang/Class;Ljava/lang/reflect/Method;)Lscala/runtime/MethodCache; | |
71: invokespecial #26 // Method java/lang/ref/SoftReference."<init>":(Ljava/lang/Object;)V | |
74: putstatic #30 // Field reflPoly$Cache1:Ljava/lang/ref/SoftReference; | |
77: aload_2 | |
78: areturn | |
public int foo(); | |
Code: | |
0: new #75 // class test/Test | |
3: dup | |
4: invokespecial #76 // Method test/Test."<init>":()V | |
7: invokevirtual #80 // Method test/Test.ugh:()Ltest/Ugh; | |
10: astore_1 | |
11: aload_1 | |
12: invokevirtual #84 // Method java/lang/Object.getClass:()Ljava/lang/Class; | |
15: invokestatic #86 // Method reflMethod$Method1:(Ljava/lang/Class;)Ljava/lang/reflect/Method; | |
18: aload_1 | |
19: iconst_0 | |
20: anewarray #4 // class java/lang/Object | |
23: invokevirtual #90 // Method java/lang/reflect/Method.invoke:(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object; | |
26: checkcast #92 // class java/lang/Integer | |
29: invokestatic #98 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I | |
32: ireturn | |
33: astore_2 | |
34: aload_2 | |
35: invokevirtual #102 // Method java/lang/reflect/InvocationTargetException.getCause:()Ljava/lang/Throwable; | |
38: athrow | |
Exception table: | |
from to target type | |
11 26 33 Class java/lang/reflect/InvocationTargetException | |
public test.Main(); | |
Code: | |
0: aload_0 | |
1: invokespecial #109 // Method java/lang/Object."<init>":()V | |
4: return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment