Last active
August 29, 2015 14:14
-
-
Save bryce-anderson/bf2cb8ac1a185b392dfb 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
public int go2(org.http4s.client.blaze.Foo$Thing); | |
Code: | |
0: aload_1 | |
1: astore_2 | |
2: aload_2 | |
3: instanceof #16 // class org/http4s/client/blaze/Foo$ThingA | |
6: ifeq 48 | |
9: aload_2 | |
10: checkcast #16 // class org/http4s/client/blaze/Foo$ThingA | |
13: astore_3 | |
14: getstatic #21 // Field org/http4s/client/blaze/Foo$ThingA$.MODULE$:Lorg/http4s/client/blaze/Foo$ThingA$; | |
17: aload_3 | |
18: invokevirtual #25 // Method org/http4s/client/blaze/Foo$ThingA$.unapply:(Lorg/http4s/client/blaze/Foo$ThingA;)Lscala/Option; | |
21: astore 4 | |
23: aload 4 | |
25: invokevirtual #31 // Method scala/Option.isEmpty:()Z | |
28: ifne 48 | |
31: aload 4 | |
33: invokevirtual #35 // Method scala/Option.get:()Ljava/lang/Object; | |
36: invokestatic #41 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I | |
39: istore 5 | |
41: iload 5 | |
43: istore 6 | |
45: goto 93 | |
48: aload_2 | |
49: instanceof #43 // class org/http4s/client/blaze/Foo$ThingB | |
52: ifeq 96 | |
55: aload_2 | |
56: checkcast #43 // class org/http4s/client/blaze/Foo$ThingB | |
59: astore 7 | |
61: getstatic #48 // Field org/http4s/client/blaze/Foo$ThingB$.MODULE$:Lorg/http4s/client/blaze/Foo$ThingB$; | |
64: aload 7 | |
66: invokevirtual #51 // Method org/http4s/client/blaze/Foo$ThingB$.unapply:(Lorg/http4s/client/blaze/Foo$ThingB;)Lscala/Option; | |
69: astore 8 | |
71: aload 8 | |
73: invokevirtual #31 // Method scala/Option.isEmpty:()Z | |
76: ifne 96 | |
79: aload 8 | |
81: invokevirtual #35 // Method scala/Option.get:()Ljava/lang/Object; | |
84: invokestatic #41 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I | |
87: istore 9 | |
89: iload 9 | |
91: istore 6 | |
93: iload 6 | |
95: ireturn | |
96: new #53 // class scala/MatchError | |
99: dup | |
100: aload_2 | |
101: invokespecial #56 // Method scala/MatchError."<init>":(Ljava/lang/Object;)V | |
104: athrow | |
public int go(scala.util.Either<java.lang.Object, java.lang.Object>); | |
Code: | |
0: aload_1 | |
1: astore_2 | |
2: aload_2 | |
3: instanceof #67 // class scala/util/Left | |
6: ifeq 30 | |
9: aload_2 | |
10: checkcast #67 // class scala/util/Left | |
13: astore_3 | |
14: aload_3 | |
15: invokevirtual #70 // Method scala/util/Left.a:()Ljava/lang/Object; | |
18: invokestatic #41 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I | |
21: istore 4 | |
23: iload 4 | |
25: istore 5 | |
27: goto 57 | |
30: aload_2 | |
31: instanceof #72 // class scala/util/Right | |
34: ifeq 60 | |
37: aload_2 | |
38: checkcast #72 // class scala/util/Right | |
41: astore 6 | |
43: aload 6 | |
45: invokevirtual #75 // Method scala/util/Right.b:()Ljava/lang/Object; | |
48: invokestatic #41 // Method scala/runtime/BoxesRunTime.unboxToInt:(Ljava/lang/Object;)I | |
51: istore 7 | |
53: iload 7 | |
55: istore 5 | |
57: iload 5 | |
59: ireturn | |
60: new #53 // class scala/MatchError | |
63: dup | |
64: aload_2 | |
65: invokespecial #56 // Method scala/MatchError."<init>":(Ljava/lang/Object;)V | |
68: athrow | |
} |
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
object Foo { | |
sealed trait Thing | |
class ThingA(val i: Int) extends Thing | |
object ThingA { | |
def unapply(thing: ThingA): Option[Int] = Some(thing.i) | |
} | |
class ThingB(val i: Int) extends Thing | |
object ThingB { | |
def unapply(thing: ThingB): Option[Int] = Some(thing.i) | |
} | |
def go2(t: Thing) = t match { | |
case ThingA(i) => i | |
case ThingB(i) => i | |
} | |
def go(a: Either[Int, Int]): Int = a match { | |
case Left(i) => i | |
case Right(i) => i | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment