From cae678648d00411b0cb55b03448ebeb46ab71065 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 11 Aug 2023 16:26:10 +0100 Subject: [PATCH] Drop showAlways on UncheckedTypePattern --- .../dotty/tools/dotc/reporting/messages.scala | 1 - tests/warn/enum-approx2.check | 8 +------- tests/warn/enum-approx2.scala | 2 +- tests/warn/i16451.check | 16 ++-------------- tests/warn/i16451.scala | 4 ++-- 5 files changed, 6 insertions(+), 25 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/messages.scala b/compiler/src/dotty/tools/dotc/reporting/messages.scala index c77f9b4fe2e1..2f9665c6eac5 100644 --- a/compiler/src/dotty/tools/dotc/reporting/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/messages.scala @@ -897,7 +897,6 @@ extends Message(PatternMatchExhaustivityID) { class UncheckedTypePattern(argType: Type, whyNot: String)(using Context) extends PatternMatchMsg(UncheckedTypePatternID) { - override def showAlways = true def msg(using Context) = i"the type test for $argType cannot be checked at runtime because $whyNot" def explain(using Context) = i"""|Type arguments and type refinements are erased during compile time, thus it's diff --git a/tests/warn/enum-approx2.check b/tests/warn/enum-approx2.check index 01e1d8f5addd..a75c15b424ff 100644 --- a/tests/warn/enum-approx2.check +++ b/tests/warn/enum-approx2.check @@ -1,5 +1,5 @@ -- [E030] Match case Unreachable Warning: tests/warn/enum-approx2.scala:7:12 ------------------------------------------- -7 | case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // warn: unchecked +7 | case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // also: unchecked (hidden) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | Unreachable case -- [E121] Pattern Match Warning: tests/warn/enum-approx2.scala:8:9 ----------------------------------------------------- @@ -12,9 +12,3 @@ |the type test for Fun[Int, Double] cannot be checked at runtime because its type arguments can't be determined from Exp[Int => Int] | | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Unchecked Warning: tests/warn/enum-approx2.scala:7:13 ------------------------------------------ -7 | case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // warn: unchecked - | ^ - |the type test for Exp[Int => String] cannot be checked at runtime because its type arguments can't be determined from Exp[Int => Int] - | - | longer explanation available when compiling with `-explain` diff --git a/tests/warn/enum-approx2.scala b/tests/warn/enum-approx2.scala index 2c2563a8b2f1..38a78cd6a5e9 100644 --- a/tests/warn/enum-approx2.scala +++ b/tests/warn/enum-approx2.scala @@ -4,7 +4,7 @@ case class Fun[A, B](f: Exp[A => B]) extends Exp[A => B] class Test { def eval(e: Fun[Int, Int]) = e match { case Fun(x: Fun[Int, Double]) => ??? // warn: unchecked - case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // warn: unchecked + case Fun(x: Exp[Int => String]) => ??? // warn: unreachable // also: unchecked (hidden) case _ => // warn: unreachable-only-null } } diff --git a/tests/warn/i16451.check b/tests/warn/i16451.check index 2bc469af480b..a966b5c85be4 100644 --- a/tests/warn/i16451.check +++ b/tests/warn/i16451.check @@ -1,9 +1,9 @@ -- [E030] Match case Unreachable Warning: tests/warn/i16451.scala:14:9 ------------------------------------------------- -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) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Unreachable case -- [E030] Match case Unreachable Warning: tests/warn/i16451.scala:22:9 ------------------------------------------------- -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) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | Unreachable case -- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:13:9 ------------------------------------------------ @@ -12,24 +12,12 @@ |the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color] | | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:14:9 ------------------------------------------------ -14 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked - | ^ - |the type test for Wrapper[(Color.Green : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color] - | - | longer explanation available when compiling with `-explain` -- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:21:9 ------------------------------------------------ 21 | case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked | ^ |the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Any | | longer explanation available when compiling with `-explain` --- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:22:9 ------------------------------------------------ -22 | case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked - | ^ - |the type test for Wrapper[(Color.Green : Color)] cannot be checked at runtime because its type arguments can't be determined from Any - | - | longer explanation available when compiling with `-explain` -- [E092] Pattern Match Unchecked Warning: tests/warn/i16451.scala:25:9 ------------------------------------------------ 25 | case x: Wrapper[Color.Red.type] => Some(x) // error: unreachable // error: unchecked | ^ diff --git a/tests/warn/i16451.scala b/tests/warn/i16451.scala index b11def9ec2ba..1a83d56366f6 100644 --- a/tests/warn/i16451.scala +++ b/tests/warn/i16451.scala @@ -11,7 +11,7 @@ case class Wrapper[A](value: A) object Test: def test_correct(x: Wrapper[Color]): Option[Wrapper[Color.Red.type]] = x match case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked - case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked + case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden) def test_different(x: Wrapper[Color]): Option[Wrapper[Color]] = x match case x @ Wrapper(_: Color.Red.type) => Some(x) @@ -19,7 +19,7 @@ object Test: def test_any(x: Any): Option[Wrapper[Color.Red.type]] = x match case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked - case x: Wrapper[Color.Green.type] => None // warn: unreachable // warn: unchecked + case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden) def test_wrong(x: Wrapper[Color]): Option[Wrapper[Color.Red.type]] = x match case x: Wrapper[Color.Red.type] => Some(x) // error: unreachable // error: unchecked