1
1
scala> def unsafeCast[S](a: Any) = a match { case s: S => s; case _ => ??? }
2
- -- [E035 ] Erased Type Unchecked Warning: <console> -----------------------------
2
+ -- [E037 ] 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
@@ -16,7 +16,7 @@ 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
- -- [E035 ] Erased Type Unchecked Warning: <console> -----------------------------
19
+ -- [E037 ] 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
@@ -27,23 +27,17 @@ 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
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
- -- [E035 ] Erased Type Unchecked Warning: <console> -----------------------------
30
+ -- [E037 ] 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
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
- -- [E035] Erased Type Unchecked Warning: <console> -----------------------------
39
- 5 |def matchArray3[A](xs: Array[A]) = xs match { case xs: Array[Int] => xs; case xs: Array[AnyRef] => ???; case xs: Array[Any] => ??? }
40
- | ^
41
- | abstract type pattern is unchecked since it is eliminated by erasure
42
-
43
- longer explanation available when compiling with `-explain`
44
38
def matchArray3[A](xs: Array[A]): [A] => (xs: Array[A])Array[Int]
45
39
scala> def matchArray4(xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ???; case xs: Array[Any] => ??? }
46
- -- [E035 ] Erased Type Unchecked Warning: <console> -----------------------------
40
+ -- [E037 ] Erased Type Unchecked Warning: <console> -----------------------------
47
41
5 |def matchArray4(xs: Array[Any]) = xs match { case xs: Array[Int] => xs; case xs: Array[A] => ???; case xs: Array[Any] => ??? }
48
42
| ^
49
43
| abstract type pattern is unchecked since it is eliminated by erasure
@@ -56,4 +50,6 @@ scala> def matchList1(xs: List[Any]) = xs match { case xs: List[Int @unchecked]
56
50
def matchList1(xs: List[Any]): Nothing
57
51
scala> def matchList2(xs: List[Any]) = xs match { case List() => ???; case _ => ??? }
58
52
def matchList2(xs: List[Any]): Nothing
53
+ scala> def matchList3(xs: Seq[_]) = xs match { case List() => ???; case _ => ??? }
54
+ def matchList3(xs: Seq[_]): Nothing
59
55
scala> :quit
0 commit comments