Skip to content

Commit cae6786

Browse files
committed
Drop showAlways on UncheckedTypePattern
1 parent 9045834 commit cae6786

File tree

5 files changed

+6
-25
lines changed

5 files changed

+6
-25
lines changed

Diff for: compiler/src/dotty/tools/dotc/reporting/messages.scala

-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,6 @@ extends Message(PatternMatchExhaustivityID) {
897897

898898
class UncheckedTypePattern(argType: Type, whyNot: String)(using Context)
899899
extends PatternMatchMsg(UncheckedTypePatternID) {
900-
override def showAlways = true
901900
def msg(using Context) = i"the type test for $argType cannot be checked at runtime because $whyNot"
902901
def explain(using Context) =
903902
i"""|Type arguments and type refinements are erased during compile time, thus it's

Diff for: tests/warn/enum-approx2.check

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- [E030] Match case Unreachable Warning: tests/warn/enum-approx2.scala:7:12 -------------------------------------------
2-
7 | case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // warn: unchecked
2+
7 | case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // also: unchecked (hidden)
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
44
| Unreachable case
55
-- [E121] Pattern Match Warning: tests/warn/enum-approx2.scala:8:9 -----------------------------------------------------
@@ -12,9 +12,3 @@
1212
|the type test for Fun[Int, Double] cannot be checked at runtime because its type arguments can't be determined from Exp[Int => Int]
1313
|
1414
| longer explanation available when compiling with `-explain`
15-
-- [E092] Pattern Match Unchecked Warning: tests/warn/enum-approx2.scala:7:13 ------------------------------------------
16-
7 | case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // warn: unchecked
17-
| ^
18-
|the type test for Exp[Int => String] cannot be checked at runtime because its type arguments can't be determined from Exp[Int => Int]
19-
|
20-
| longer explanation available when compiling with `-explain`

Diff for: tests/warn/enum-approx2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ case class Fun[A, B](f: Exp[A => B]) extends Exp[A => B]
44
class Test {
55
def eval(e: Fun[Int, Int]) = e match {
66
case Fun(x: Fun[Int, Double]) => ??? // warn: unchecked
7-
case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // warn: unchecked
7+
case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // also: unchecked (hidden)
88
case _ => // warn: unreachable-only-null
99
}
1010
}

Diff for: tests/warn/i16451.check

+2-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
-- [E030] Match case Unreachable Warning: tests/warn/i16451.scala:14:9 -------------------------------------------------
2-
14 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked
2+
14 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden)
33
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
44
| Unreachable case
55
-- [E030] Match case Unreachable Warning: tests/warn/i16451.scala:22:9 -------------------------------------------------
6-
22 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked
6+
22 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden)
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88
| Unreachable case
99
-- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:13:9 ------------------------------------------------
@@ -12,24 +12,12 @@
1212
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color]
1313
|
1414
| longer explanation available when compiling with `-explain`
15-
-- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:14:9 ------------------------------------------------
16-
14 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked
17-
| ^
18-
|the type test for Wrapper[(Color.Green : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color]
19-
|
20-
| longer explanation available when compiling with `-explain`
2115
-- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:21:9 ------------------------------------------------
2216
21 | case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
2317
| ^
2418
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Any
2519
|
2620
| longer explanation available when compiling with `-explain`
27-
-- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:22:9 ------------------------------------------------
28-
22 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked
29-
| ^
30-
|the type test for Wrapper[(Color.Green : Color)] cannot be checked at runtime because its type arguments can't be determined from Any
31-
|
32-
| longer explanation available when compiling with `-explain`
3321
-- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:25:9 ------------------------------------------------
3422
25 | case x: Wrapper[Color.Red.type] => Some(x) // error: unreachable // error: unchecked
3523
| ^

Diff for: tests/warn/i16451.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ case class Wrapper[A](value: A)
1111
object Test:
1212
def test_correct(x: Wrapper[Color]): Option[Wrapper[Color.Red.type]] = x match
1313
case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
14-
case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked
14+
case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden)
1515

1616
def test_different(x: Wrapper[Color]): Option[Wrapper[Color]] = x match
1717
case x @ Wrapper(_: Color.Red.type) => Some(x)
1818
case x @ Wrapper(_: Color.Green.type) => None
1919

2020
def test_any(x: Any): Option[Wrapper[Color.Red.type]] = x match
2121
case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
22-
case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked
22+
case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden)
2323

2424
def test_wrong(x: Wrapper[Color]): Option[Wrapper[Color.Red.type]] = x match
2525
case x: Wrapper[Color.Red.type] => Some(x) // error: unreachable // error: unchecked

0 commit comments

Comments
 (0)