You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classAclassBtypeAorB=A|Bdeffoo(any: Any) = any match {
caseaorb: AorB=>
println("got AorB")
}
[warn] -- Warning: .../unions.scala:5:7
[warn] 5 | case aorb: AorB =>
[warn] | ^^^^^^^^^^
[warn] | the type test for AorB cannot be checked at runtime
[warn] one warning found
This warning is incorrect as the correct instanceof checks are generated in the class file:
public void foo(java.lang.Object);
descriptor: (Ljava/lang/Object;)V
flags: (0x0001) ACC_PUBLIC
Code:
stack=2, locals=5, args_size=2
0: aload_1
1: astore_2
2: aload_2
3: instanceof #20 // class example/A
6: ifne 16
9: aload_2
10: instanceof #22 // class example/B
13: ifeq 35
16: aload_2
17: checkcast #4 // class java/lang/Object
20: astore_3
21: aload_3
22: astore 4
24: getstatic #27 // Field scala/Predef$.MODULE$:Lscala/Predef$;
27: ldc #40 // String got AorB
29: invokevirtual #32 // Method scala/Predef$.println:(Ljava/lang/Object;)V
32: goto 46
35: getstatic #27 // Field scala/Predef$.MODULE$:Lscala/Predef$;
38: ldc #34 // String got Any
40: invokevirtual #32 // Method scala/Predef$.println:(Ljava/lang/Object;)V
43: goto 46
46: return
LocalVariableTable:
Start Length Slot Name Signature
22 13 4 ab Ljava/lang/Object;
0 47 0 this Lexample/Demo$;
0 47 1 foo Ljava/lang/Object;
LineNumberTable:
line 19: 0
line 20: 0
line 22: 2
line 23: 24
line 25: 35
StackMapTable: number_of_entries = 3
frame_type = 252 /* append */
offset_delta = 16
locals = [ class java/lang/Object ]
frame_type = 18 /* same */
frame_type = 10 /* same */
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Valid for Dotty 0.23.0-RC1 as of 5/04/2020:
Minimised example
This warning is incorrect as the correct instanceof checks are generated in the class file:
The text was updated successfully, but these errors were encountered: