Skip to content

Instantly share code, notes, and snippets.

@dwijnand
Last active March 24, 2018 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwijnand/ae1a3bf80adda0c1fbf4185b6eef71a7 to your computer and use it in GitHub Desktop.
Save dwijnand/ae1a3bf80adda0c1fbf4185b6eef71a7 to your computer and use it in GitHub Desktop.
diff --git a/Main$.class b/Main$.class
index cb3a2d6..06067c6 100644
--- a/Main$.class
+++ b/Main$.class
@@ -28,23 +28,12 @@ public final class Main$ {
##: aload_3
##: instanceof ### // class Recovered2
##: ifeq ##
-##: aload_3
-##: checkcast ### // class Recovered2
-##: astore ##
-##: getstatic ### // Field Recovered2$.MODULE$:LRecovered2$;
-##: aload ##
-##: invokevirtual ### // Method Recovered2$.unapply:(LRecovered2;)Lscala/Some;
-##: astore ##
-##: aload ##
-##: invokevirtual ### // Method scala/Some.isEmpty:()Z
-##: ifne ##
##: ldc ### // String case ##
##: pop
##: getstatic ### // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit;
##: astore_2
##: goto ##
##: goto ##
-##: goto ##
##: new ### // class scala/MatchError
##: dup
##: aload_3
diff --git a/Main.scala b/Main.scala
index 1471b83..f3ec62f 100644
--- a/Main.scala
+++ b/Main.scala
@@ -8,8 +8,8 @@ object Recovered2 {
object Main {
def main(x: Any): Unit = {
x match {
- case r @ Recovered(_, _) => "case 1"
- case r @ Recovered2(_, _) => "case 2"
+ case r: Recovered => "case 1"
+ case r: Recovered2 => "case 2"
}
}
}
final case class Recovered(x: Int, s: String)
final class Recovered2(val x: Int, val s: String)
object Recovered2 {
def unapply(x: Recovered2): Some[(Int, String)] = Some((x.x, x.s))
}
object Main {
def main(x: Any): Unit = {
x match {
case r: Recovered => "case 1"
case r: Recovered2 => "case 2"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment