File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 118: Pattern Match Exhaustivity: Foo(Inactive)
2+ 17: Pattern Match Exhaustivity: Foo(Status.Active(_))
Original file line number Diff line number Diff line change 11sealed trait Status
22object Status {
3- case object Active extends Status
3+ case class Active ( since : Int ) extends Status
44 case object Inactive extends Status
55}
66
77case class Foo (status : Status )
8- def bar (user : Foo ): Unit = user match {
9- case Foo (Status .Active ) =>
10- println(" active" )
11- // no compile-time warning for missing Status.Inactive case
8+ def bar (foo : Foo ): Unit = foo match {
9+ case Foo (Status .Active (since)) =>
10+ println(s " active since $since" )
1211}
12+ // Expected:
13+ // warning: match may not be exhaustive.
14+ // It would fail on the following input: Foo(Inactive)
15+ // def bar(foo: Foo): Unit = foo match {
16+
17+ def baz (foo : Foo ): Unit = foo match {
18+ case Foo (Status .Active (2000 )) =>
19+ println(" active since 2000" )
20+ case Foo (Status .Inactive ) =>
21+ println(" inactive" )
22+ }
23+ // Expected:
24+ // warning: match may not be exhaustive.
25+ // It would fail on the following input: Foo(Active((x: Int forSome x not in 2000)))
26+ // def baz(foo: Foo): Unit = foo match {
You can’t perform that action at this time.
0 commit comments