Skip to content

Commit 3340ba6

Browse files
committed
Test order-dependent reachability warnings
1 parent 3a8274c commit 3340ba6

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/patmat/i13485.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
16: Match case Unreachable

tests/patmat/i13485.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// The intent of this test is test that changing the order of cases doesn't affect whether
2+
// warnings, originally reachability warnings but exhaustivity warnings too, are emitted.
3+
// To do so we need a case that typechecks but is statically assessed to be unreachable.
4+
// How about... a type pattern on a sealed trait that the scrutinee type doesn't extend?
5+
6+
sealed trait Foo
7+
8+
class Bar
9+
10+
def test1(bar: Bar) = bar match
11+
case _: Foo => 1
12+
case _: Bar => 2
13+
14+
def test2(bar: Bar) = bar match
15+
case _: Bar => 2
16+
case _: Foo => 1

0 commit comments

Comments
 (0)