Skip to content

Commit 3c3329b

Browse files
authored
Merge pull request #14104 from dwijnand/bport/fix-case-seq-match-vector
2 parents 7dffdb1 + a4c540b commit 3c3329b

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,9 @@ class SpaceEngine(using Context) extends SpaceLogic {
953953
if prev == Empty && covered == Empty then // defer until a case is reachable
954954
deferred ::= pat
955955
else {
956-
for (pat <- deferred.reverseIterator)
957-
report.warning(MatchCaseUnreachable(), pat.srcPos)
956+
// FIXME: These should be emitted, but reverted for i13931
957+
//for (pat <- deferred.reverseIterator)
958+
// report.warning(MatchCaseUnreachable(), pat.srcPos)
958959
if pat != EmptyTree // rethrow case of catch uses EmptyTree
959960
&& isSubspace(covered, prev)
960961
then {
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

-1
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

+1-1
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

+4
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)