1
1
scala> def unsafeCast[S](a: Any) = a match { case s: S => s; case _ => ??? }
2
- -- [E037 ] Erased Type Unchecked Warning: <console> -----------------------------
2
+ -- [E048 ] Erased Type Unchecked Warning: <console> -----------------------------
3
3
4 |def unsafeCast[S](a: Any) = a match { case s: S => s; case _ => ??? }
4
4
| ^
5
5
| abstract type pattern is unchecked since it is eliminated by erasure
6
6
7
7
longer explanation available when compiling with `-explain`
8
- def unsafeCast[S](a: Any): [S] => (a: Any)S
8
+ def unsafeCast[S](a: Any): [S](a: Any)S
9
9
scala> unsafeCast[String](1)
10
10
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
11
11
at .<init>(<console>:6)
@@ -16,36 +16,36 @@ java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Stri
16
16
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17
17
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav...
18
18
scala> class A; def unsafeCast2[S <: A](a: Any) = a match { case s: S => s; case _ => ??? }
19
- -- [E037 ] Erased Type Unchecked Warning: <console> -----------------------------
19
+ -- [E048 ] Erased Type Unchecked Warning: <console> -----------------------------
20
20
4 |class A; def unsafeCast2[S <: A](a: Any) = a match { case s: S => s; case _ => ??? }
21
21
| ^
22
22
| abstract type pattern is unchecked since it is eliminated by erasure
23
23
24
24
longer explanation available when compiling with `-explain`
25
25
defined class A
26
- def unsafeCast2[S <: A](a: Any): [S <: A] => (a: Any)S
26
+ def unsafeCast2[S <: A](a: Any): [S <: A](a: Any)S
27
27
scala> def matchArray1[A](xs: Array[A]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ??? }
28
- def matchArray1[A](xs: Array[A]): [A] => (xs: Array[A])Array[Int]
28
+ def matchArray1[A](xs: Array[A]): [A](xs: Array[A])Array[Int]
29
29
scala> def matchArray2[A](xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ??? }
30
- -- [E037 ] Erased Type Unchecked Warning: <console> -----------------------------
30
+ -- [E048 ] Erased Type Unchecked Warning: <console> -----------------------------
31
31
5 |def matchArray2[A](xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ??? }
32
32
| ^
33
33
| abstract type pattern is unchecked since it is eliminated by erasure
34
34
35
35
longer explanation available when compiling with `-explain`
36
- def matchArray2[A](xs: Array[Any]): [A] => (xs: Array[Any])Array[Int]
36
+ def matchArray2[A](xs: Array[Any]): [A](xs: Array[Any])Array[Int]
37
37
scala> def matchArray3[A](xs: Array[A]) = xs match { case xs: Array[Int] => xs; case xs: Array[AnyRef] => ???; case xs: Array[Any] => ??? }
38
- def matchArray3[A](xs: Array[A]): [A] => (xs: Array[A])Array[Int]
38
+ def matchArray3[A](xs: Array[A]): [A](xs: Array[A])Array[Int]
39
39
scala> def matchArray4(xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ???; case xs: Array[Any] => ??? }
40
- -- [E037 ] Erased Type Unchecked Warning: <console> -----------------------------
40
+ -- [E048 ] Erased Type Unchecked Warning: <console> -----------------------------
41
41
5 |def matchArray4(xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ???; case xs: Array[Any] => ??? }
42
42
| ^
43
43
| abstract type pattern is unchecked since it is eliminated by erasure
44
44
45
45
longer explanation available when compiling with `-explain`
46
46
def matchArray4(xs: Array[Any]): Array[Int]
47
47
scala> def matchArray5[A](xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A @unchecked] => ??? }
48
- def matchArray5[A](xs: Array[Any]): [A] => (xs: Array[Any])Array[Int]
48
+ def matchArray5[A](xs: Array[Any]): [A](xs: Array[Any])Array[Int]
49
49
scala> def matchList1(xs: List[Any]) = xs match { case xs: List[Int @unchecked] => ??? }
50
50
def matchList1(xs: List[Any]): Nothing
51
51
scala> def matchList2(xs: List[Any]) = xs match { case List() => ???; case _ => ??? }
0 commit comments