Skip to content

Commit caae26a

Browse files
committed
Revert Unsuppress unchecked warnings
This reverts commit 9045834 due to introduced regression
1 parent ebf5ae1 commit caae26a

File tree

13 files changed

+54
-98
lines changed

13 files changed

+54
-98
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ abstract class Message(val errorId: ErrorMessageID)(using Context) { self =>
405405
override def canExplain = true
406406

407407
/** Override with `true` for messages that should always be shown even if their
408-
* position overlaps another message of a different class. On the other hand
408+
* position overlaps another messsage of a different class. On the other hand
409409
* multiple messages of the same class with overlapping positions will lead
410410
* to only a single message of that class to be issued.
411411
*/

Diff for: compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ object TypeTestsCasts {
7474
}.apply(tp)
7575

7676
/** Returns true if the type arguments of `P` can be determined from `X` */
77-
def typeArgsDeterminable(X: Type, P: AppliedType)(using Context) = inContext(ctx.fresh.setExploreTyperState().setFreshGADTBounds) {
77+
def typeArgsTrivial(X: Type, P: AppliedType)(using Context) = inContext(ctx.fresh.setExploreTyperState().setFreshGADTBounds) {
7878
val AppliedType(tycon, _) = P
7979

8080
def underlyingLambda(tp: Type): TypeLambda = tp.ensureLambdaSub match {
@@ -161,7 +161,7 @@ object TypeTestsCasts {
161161
val tparams = x.typeParams
162162
if tparams.isEmpty then x else x.appliedTo(tparams.map(_ => WildcardType))
163163
TypeComparer.provablyDisjoint(xApplied, tpe.derivedAppliedType(tycon, targs.map(_ => WildcardType)))
164-
|| typeArgsDeterminable(X, tpe)
164+
|| typeArgsTrivial(X, tpe)
165165
||| i"its type arguments can't be determined from $X"
166166
}
167167
case AndType(tp1, tp2) => recur(X, tp1) && recur(X, tp2)

Diff for: compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ object SpaceEngine {
370370
project(pat)
371371

372372
case Typed(_, tpt) =>
373-
Typ(erase(tpt.tpe.stripAnnots, isValue = true, isTyped = true), decomposed = false)
373+
Typ(erase(tpt.tpe.stripAnnots, isValue = true), decomposed = false)
374374

375375
case This(_) =>
376376
Typ(pat.tpe.stripAnnots, decomposed = false)
@@ -455,13 +455,13 @@ object SpaceEngine {
455455
tp.derivedAppliedType(erase(tycon, inArray, isValue = false), args2)
456456

457457
case tp @ OrType(tp1, tp2) =>
458-
OrType(erase(tp1, inArray, isValue, isTyped), erase(tp2, inArray, isValue, isTyped), tp.isSoft)
458+
OrType(erase(tp1, inArray, isValue), erase(tp2, inArray, isValue), tp.isSoft)
459459

460460
case AndType(tp1, tp2) =>
461-
AndType(erase(tp1, inArray, isValue, isTyped), erase(tp2, inArray, isValue, isTyped))
461+
AndType(erase(tp1, inArray, isValue), erase(tp2, inArray, isValue))
462462

463463
case tp @ RefinedType(parent, _, _) =>
464-
erase(parent, inArray, isValue, isTyped)
464+
erase(parent, inArray, isValue)
465465

466466
case tref: TypeRef if tref.symbol.isPatternBound =>
467467
if inArray then erase(tref.underlying, inArray, isValue, isTyped)

Diff for: tests/pending/neg/i16451.check

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- Error: tests/neg/i16451.scala:13:9 ----------------------------------------------------------------------------------
2+
13 | case x: Wrapper[Color.Red.type] => Some(x) // error
3+
| ^
4+
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color]
5+
-- Error: tests/neg/i16451.scala:21:9 ----------------------------------------------------------------------------------
6+
21 | case x: Wrapper[Color.Red.type] => Some(x) // error
7+
| ^
8+
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Any
9+
-- Error: tests/neg/i16451.scala:25:9 ----------------------------------------------------------------------------------
10+
25 | case x: Wrapper[Color.Red.type] => Some(x) // error
11+
| ^
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]
13+
-- Error: tests/neg/i16451.scala:29:9 ----------------------------------------------------------------------------------
14+
29 | case x: Wrapper[Color.Red.type] => Some(x) // error
15+
| ^
16+
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from A1
17+
-- Error: tests/neg/i16451.scala:34:11 ---------------------------------------------------------------------------------
18+
34 | case x: Wrapper[Color.Red.type] => x // error
19+
| ^
20+
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color]
21+
-- Error: tests/neg/i16451.scala:39:11 ---------------------------------------------------------------------------------
22+
39 | case x: Wrapper[Color.Red.type] => x // error
23+
| ^
24+
|the type test for Wrapper[(Color.Red : Color)] cannot be checked at runtime because its type arguments can't be determined from Wrapper[Color]

Diff for: tests/warn/i16451.scala renamed to tests/pending/neg/i16451.scala

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
1-
//
1+
//> using options -Werror
22
enum Color:
33
case Red, Green
4-
//sealed trait Color
5-
//object Color:
6-
// case object Red extends Color
7-
// case object Green extends Color
84

95
case class Wrapper[A](value: A)
106

117
object Test:
128
def test_correct(x: Wrapper[Color]): Option[Wrapper[Color.Red.type]] = x match
13-
case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
14-
case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden)
9+
case x: Wrapper[Color.Red.type] => Some(x) // error
10+
case null => None
1511

1612
def test_different(x: Wrapper[Color]): Option[Wrapper[Color]] = x match
1713
case x @ Wrapper(_: Color.Red.type) => Some(x)
1814
case x @ Wrapper(_: Color.Green.type) => None
1915

2016
def test_any(x: Any): Option[Wrapper[Color.Red.type]] = x match
21-
case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
22-
case x: Wrapper[Color.Green.type] => None // warn: unreachable // also: unchecked (hidden)
17+
case x: Wrapper[Color.Red.type] => Some(x) // error
18+
case _ => None
2319

2420
def test_wrong(x: Wrapper[Color]): Option[Wrapper[Color.Red.type]] = x match
25-
case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
21+
case x: Wrapper[Color.Red.type] => Some(x) // error
2622
case null => None
2723

2824
def t2[A1 <: Wrapper[Color]](x: A1): Option[Wrapper[Color.Red.type]] = x match
29-
case x: Wrapper[Color.Red.type] => Some(x) // warn: unchecked
25+
case x: Wrapper[Color.Red.type] => Some(x) // error
3026
case null => None
3127

3228
def test_wrong_seq(xs: Seq[Wrapper[Color]]): Seq[Wrapper[Color.Red.type]] =
3329
xs.collect {
34-
case x: Wrapper[Color.Red.type] => x // warn: unchecked
30+
case x: Wrapper[Color.Red.type] => x // error
3531
}
3632

3733
def test_wrong_seq2(xs: Seq[Wrapper[Color]]): Seq[Wrapper[Color.Red.type]] =
3834
xs.collect { x => x match
39-
case x: Wrapper[Color.Red.type] => x // warn: unchecked
35+
case x: Wrapper[Color.Red.type] => x // error
4036
}
4137

4238
def main(args: Array[String]): Unit =

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

-14
This file was deleted.

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

-10
This file was deleted.

Diff for: tests/warn/i11178.scala

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ object Test1 {
1212
def test[A](bar: Bar[A]) =
1313
bar match {
1414
case _: Bar[Boolean] => ??? // warn
15+
case _ => ???
1516
}
1617
}
1718

@@ -22,6 +23,7 @@ object Test2 {
2223
def test[A](bar: Bar[A]) =
2324
bar match {
2425
case _: Bar[Boolean] => ??? // warn
26+
case _ => ???
2527
}
2628
}
2729

@@ -32,5 +34,6 @@ object Test3 {
3234
def test[A](bar: Bar[A]) =
3335
bar match {
3436
case _: Bar[Boolean] => ??? // warn
37+
case _ => ???
3538
}
3639
}

Diff for: tests/warn/i16451.check

-44
This file was deleted.

Diff for: tests/warn/i5826.check

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
|the type test for List[Int] cannot be checked at runtime because its type arguments can't be determined from List[String]
1111
|
1212
| longer explanation available when compiling with `-explain`
13-
-- [E092] Pattern Match Unchecked Warning: tests/warn/i5826.scala:16:9 -------------------------------------------------
14-
16 | case ls: A[X] => 4 // warn
13+
-- [E092] Pattern Match Unchecked Warning: tests/warn/i5826.scala:17:9 -------------------------------------------------
14+
17 | case ls: A[X] => 4 // warn
1515
| ^
1616
|the type test for Foo.this.A[X] cannot be checked at runtime because its type arguments can't be determined from Foo.this.B[X]
1717
|
1818
| longer explanation available when compiling with `-explain`
19-
-- [E092] Pattern Match Unchecked Warning: tests/warn/i5826.scala:21:9 -------------------------------------------------
20-
21 | case ls: List[Int] => ls.head // warn, List extends Int => T
19+
-- [E092] Pattern Match Unchecked Warning: tests/warn/i5826.scala:22:9 -------------------------------------------------
20+
22 | case ls: List[Int] => ls.head // warn, List extends Int => T
2121
| ^
2222
|the type test for List[Int] cannot be checked at runtime because its type arguments can't be determined from A => Int
2323
|
2424
| longer explanation available when compiling with `-explain`
25-
-- [E092] Pattern Match Unchecked Warning: tests/warn/i5826.scala:27:54 ------------------------------------------------
26-
27 | def test5[T](x: A[T] | B[T] | Option[T]): Boolean = x.isInstanceOf[C[String]] // warn
25+
-- [E092] Pattern Match Unchecked Warning: tests/warn/i5826.scala:28:54 ------------------------------------------------
26+
28 | def test5[T](x: A[T] | B[T] | Option[T]): Boolean = x.isInstanceOf[C[String]] // warn
2727
| ^
2828
|the type test for Foo.this.C[String] cannot be checked at runtime because its type arguments can't be determined from Foo.this.A[T]
2929
|

Diff for: tests/warn/i5826.scala

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Foo {
66

77
def test2: List[Int] | List[String] => Int = {
88
case ls: List[Int] => ls.head // warn: unchecked
9+
case _ => 0
910
}
1011

1112
trait A[T]

Diff for: tests/warn/i8932.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Dummy extends Bar[Nothing] with Foo[String]
66
def bugReport[A](foo: Foo[A]): Foo[A] =
77
foo match {
88
case bar: Bar[A] => bar // warn: unchecked
9-
case dummy: Dummy => ??? // warn: unreachable
9+
case dummy: Dummy => ???
1010
}
1111

1212
def test = bugReport(new Dummy: Foo[String])

Diff for: tests/warn/suppressed-type-test-warnings.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
object Test {
22
sealed trait Foo[A, B]
33
final case class Bar[X](x: X) extends Foo[X, X]
4-
54
def foo[A, B](value: Foo[A, B], a: A => Int): B = value match {
65
case Bar(x) => a(x); x
76
}
8-
97
def bar[A, B](value: Foo[A, B], a: A => Int): B = value match {
108
case b: Bar[a] => b.x
119
}
@@ -18,10 +16,12 @@ object Test {
1816
def err2[A, B](value: Foo[A, B], a: A => Int): B = value match {
1917
case b: Bar[B] => // spurious // warn
2018
b.x
19+
case _ => ??? // avoid fatal inexhaustivity warnings suppressing the uncheckable warning
2120
}
2221

2322
def fail[A, B](value: Foo[A, B], a: A => Int): B = value match {
2423
case b: Bar[Int] => // warn
2524
b.x
25+
case _ => ??? // avoid fatal inexhaustivity warnings suppressing the uncheckable warning
2626
}
27-
}
27+
}

0 commit comments

Comments
 (0)