forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathi15503d.scala
30 lines (26 loc) · 906 Bytes
/
i15503d.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//> using options -Wunused:unsafe-warn-patvars
// todo : change to :patvars
sealed trait Calc
sealed trait Const extends Calc
case class Sum(a: Calc, b: Calc) extends Calc
case class S(pred: Const) extends Const
case object Z extends Const
val a = Sum(S(S(Z)),Z) match {
case Sum(a,Z) => Z // warn
// case Sum(a @ _,Z) => Z // todo : this should pass in the future
case Sum(a@S(_),Z) => Z // warn
case Sum(a@S(_),Z) => a // warn unreachable
case Sum(a@S(b@S(_)), Z) => a // warn
case Sum(a@S(b@S(_)), Z) => a // warn
case Sum(a@S(b@(S(_))), Z) => Sum(a,b) // warn unreachable
case Sum(_,_) => Z // OK
case _ => Z // warn unreachable
}
// todo : This should pass in the future
// val b = for {
// case Some(x) <- Option(Option(1))
// } println(s"$x")
// todo : This should *NOT* pass in the future
// val c = for {
// case Some(x) <- Option(Option(1))
// } println(s"hello world")