Skip to content

Instantly share code, notes, and snippets.

@NthPortal
Created October 25, 2018 04:06
Show Gist options
  • Save NthPortal/4d2ce4a7882709a5b1bbcba1e677f17e to your computer and use it in GitHub Desktop.
Save NthPortal/4d2ce4a7882709a5b1bbcba1e677f17e to your computer and use it in GitHub Desktop.
scala> class Foo {
| def p1[A, B](t: (A, B)): (Option[A], Option[B]) = {
| val (e1, e2) = t
| (Some(e1), Some(e2))
| }
| def p2[A, B](t: (A, B)): (Option[A], Option[B]) = {
| (Some(t._1), Some(t._2))
| }
| }
defined class Foo
scala> :javap -c Foo
Compiled from "<console>"
public class $line4.$read$$iw$$iw$Foo {
public <A, B> scala.Tuple2<scala.Option<A>, scala.Option<B>> p1(scala.Tuple2<A, B>);
Code:
0: aload_1
1: astore 4
3: aload 4
5: ifnull 37
8: aload 4
10: invokevirtual #22 // Method scala/Tuple2._1:()Ljava/lang/Object;
13: astore 5
15: aload 4
17: invokevirtual #25 // Method scala/Tuple2._2:()Ljava/lang/Object;
20: astore 6
22: new #18 // class scala/Tuple2
25: dup
26: aload 5
28: aload 6
30: invokespecial #29 // Method scala/Tuple2."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
33: astore_2
34: goto 50
37: goto 40
40: new #31 // class scala/MatchError
43: dup
44: aload 4
46: invokespecial #34 // Method scala/MatchError."<init>":(Ljava/lang/Object;)V
49: athrow
50: aload_2
51: astore_3
52: aload_3
53: invokevirtual #22 // Method scala/Tuple2._1:()Ljava/lang/Object;
56: astore 7
58: aload_3
59: invokevirtual #25 // Method scala/Tuple2._2:()Ljava/lang/Object;
62: astore 8
64: new #18 // class scala/Tuple2
67: dup
68: new #36 // class scala/Some
71: dup
72: aload 7
74: invokespecial #37 // Method scala/Some."<init>":(Ljava/lang/Object;)V
77: new #36 // class scala/Some
80: dup
81: aload 8
83: invokespecial #37 // Method scala/Some."<init>":(Ljava/lang/Object;)V
86: invokespecial #29 // Method scala/Tuple2."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
89: areturn
public <A, B> scala.Tuple2<scala.Option<A>, scala.Option<B>> p2(scala.Tuple2<A, B>);
Code:
0: new #18 // class scala/Tuple2
3: dup
4: new #36 // class scala/Some
7: dup
8: aload_1
9: invokevirtual #22 // Method scala/Tuple2._1:()Ljava/lang/Object;
12: invokespecial #37 // Method scala/Some."<init>":(Ljava/lang/Object;)V
15: new #36 // class scala/Some
18: dup
19: aload_1
20: invokevirtual #25 // Method scala/Tuple2._2:()Ljava/lang/Object;
23: invokespecial #37 // Method scala/Some."<init>":(Ljava/lang/Object;)V
26: invokespecial #29 // Method scala/Tuple2."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
29: areturn
public $line4.$read$$iw$$iw$Foo();
Code:
0: aload_0
1: invokespecial #47 // 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