File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ import scala .language .experimental .matchWithSubCases
2+
3+ object Test :
4+ val x : Option [Option [Int ]] = ???
5+ x match
6+ case Some (x2) with x2 match
7+ case Some (x3) with x3 match
8+ case 1 => " a"
9+ case 2 => " b"
10+ case None => " d"
11+
12+ x match {
13+ case Some (x2) with x2 match {
14+ case Some (x3) with x3 match {
15+ case 1 => " a"
16+ case 2 => " b"
17+ }
18+ }
19+ case None => " d"
20+ }
Original file line number Diff line number Diff line change 1+ import scala .language .experimental .matchWithSubCases
2+
3+ enum E extends Exception :
4+ case A (x : Any )
5+ case B (x : Any )
6+ case C
7+
8+ end E
9+ import E .*
10+
11+ def test (op : => Nothing ): String =
12+ try op catch
13+ case A (x : Int ) if true with x match
14+ case 1 => " A(1)"
15+ case 2 => " A(2)"
16+ case B (x : String ) with x match
17+ case " a" => " B(a)"
18+ case " b" => " B(b)"
19+ case _ => " other"
20+ end test
21+
22+ @ main def Test =
23+
24+ def check (e : E , r : String ): Unit = assert(test(throw e) == r)
25+
26+ check(A (1 ), " A(1)" )
27+ check(A (2 ), " A(2)" )
28+ check(A (3 ), " other" )
29+ check(B (" b" ), " B(b)" )
30+ check(B (1 ), " other" )
You can’t perform that action at this time.
0 commit comments