Skip to content

Commit 772c1bc

Browse files
committed
Revert to fix false positive reachability warnings
1 parent dcb123d commit 772c1bc

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -959,8 +959,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
959959
if prev == Empty && covered == Empty then // defer until a case is reachable
960960
deferred ::= pat
961961
else {
962-
for (pat <- deferred.reverseIterator)
963-
report.warning(MatchCaseUnreachable(), pat.srcPos)
962+
// FIXME: These should be emitted, but reverted for i13931
963+
//for (pat <- deferred.reverseIterator)
964+
// report.warning(MatchCaseUnreachable(), pat.srcPos)
964965
if pat != EmptyTree // rethrow case of catch uses EmptyTree
965966
&& isSubspace(covered, prev)
966967
then {
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
-- [E030] Match case Unreachable Error: tests/neg-custom-args/fatal-warnings/i8711.scala:7:9 ---------------------------
1+
-- Error: tests/neg-custom-args/fatal-warnings/i8711.scala:7:9 ---------------------------------------------------------
22
7 | case x: B => x // error: this case is unreachable since class A is not a subclass of class B
3-
| ^^^^
4-
| Unreachable case
5-
-- [E030] Match case Unreachable Error: tests/neg-custom-args/fatal-warnings/i8711.scala:12:9 --------------------------
3+
| ^
4+
| this case is unreachable since type A and class B are unrelated
5+
-- Error: tests/neg-custom-args/fatal-warnings/i8711.scala:12:9 --------------------------------------------------------
66
12 | case x: C => x // error
7-
| ^^^^
8-
| Unreachable case
7+
| ^
8+
| this case is unreachable since type A | B and class C are unrelated

tests/patmat/i13485.check

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
11: Match case Unreachable
21
16: Match case Unreachable

tests/patmat/i13485.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sealed trait Foo
88
class Bar
99

1010
def test1(bar: Bar) = bar match
11-
case _: Foo => 1
11+
case _: Foo => 1 // FIXME: this is unreachable, but reverted for i13931
1212
case _: Bar => 2
1313

1414
def test2(bar: Bar) = bar match

tests/patmat/i13931.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Test:
2+
def test = Vector() match
3+
case Seq() => println("empty")
4+
case _ => println("non-empty")

0 commit comments

Comments
 (0)