Last active
August 6, 2019 12:28
-
-
Save kmizu/a89e73dc6f55f8f774dc1ccf6ef05ad5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$ Compiled from "StringLiteralType.scala" | |
public final class StringLiteralType$ implements scala.Serializable { | |
public static final StringLiteralType$ MODULE$; | |
public static {}; | |
Code: | |
0: new #2 // class StringLiteralType$ | |
3: invokespecial #14 // Method "<init>":()V | |
6: return | |
public void isAType(java.lang.String); | |
Code: | |
0: aload_1 | |
1: astore_2 | |
2: ldc #29 // String a | |
4: aload_2 | |
5: invokevirtual #33 // Method java/lang/Object.equals:(Ljava/lang/Object;)Z | |
8: ifeq 22 | |
11: getstatic #38 // Field scala/Predef$.MODULE$:Lscala/Predef$; | |
14: ldc #40 // String This is `a` type | |
16: invokevirtual #44 // Method scala/Predef$.println:(Ljava/lang/Object;)V | |
19: goto 33 | |
22: getstatic #38 // Field scala/Predef$.MODULE$:Lscala/Predef$; | |
25: ldc #46 // String not `a` | |
27: invokevirtual #44 // Method scala/Predef$.println:(Ljava/lang/Object;)V | |
30: goto 33 | |
33: return | |
public void a1(); | |
Code: | |
0: aload_0 | |
1: ldc #29 // String a | |
3: invokevirtual #53 // Method isAType:(Ljava/lang/String;)V | |
6: return | |
public void a2(); | |
Code: | |
0: aload_0 | |
1: new #50 // class java/lang/String | |
4: dup | |
5: ldc #29 // String a | |
7: invokespecial #56 // Method java/lang/String."<init>":(Ljava/lang/String;)V | |
10: invokevirtual #53 // Method isAType:(Ljava/lang/String;)V | |
13: return | |
public boolean a3(); | |
Code: | |
0: new #50 // class java/lang/String | |
3: dup | |
4: ldc #29 // String a | |
6: invokespecial #56 // Method java/lang/String."<init>":(Ljava/lang/String;)V | |
9: ldc #29 // String a | |
11: if_acmpne 18 | |
14: iconst_1 | |
15: goto 19 | |
18: iconst_0 | |
19: ireturn | |
public void main(java.lang.String[]); | |
Code: | |
0: getstatic #38 // Field scala/Predef$.MODULE$:Lscala/Predef$; | |
3: aload_0 | |
4: invokevirtual #62 // Method a1:()V | |
7: getstatic #68 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit; | |
10: invokevirtual #44 // Method scala/Predef$.println:(Ljava/lang/Object;)V | |
13: getstatic #38 // Field scala/Predef$.MODULE$:Lscala/Predef$; | |
16: aload_0 | |
17: invokevirtual #70 // Method a2:()V | |
20: getstatic #68 // Field scala/runtime/BoxedUnit.UNIT:Lscala/runtime/BoxedUnit; | |
23: invokevirtual #44 // Method scala/Predef$.println:(Ljava/lang/Object;)V | |
26: getstatic #38 // Field scala/Predef$.MODULE$:Lscala/Predef$; | |
29: aload_0 | |
30: invokevirtual #72 // Method a3:()Z | |
33: invokestatic #78 // Method scala/runtime/BoxesRunTime.boxToBoolean:(Z)Ljava/lang/Boolean; | |
36: invokevirtual #44 // Method scala/Predef$.println:(Ljava/lang/Object;)V | |
39: return | |
} |
This file contains hidden or 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 StringLiteralType { | |
def isAType(arg: String): Unit = arg match { | |
case _ : "a" => println("This is `a` type") | |
case _ => println("not `a`") | |
} | |
def a1 = isAType("a") | |
def a2 = isAType(new String("a")) | |
def a3 = new String("a").isInstanceOf["a"] | |
def main(args: Array[String]): Unit = { | |
println(a1) | |
println(a2) | |
println(a3) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment