blob: 0541ed61f95b49d4a810baefff4920483e2dbe6b (
plain) (
blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
object Test {
sealed trait Expr[T]
case class IntLit(i: Int) extends Expr[Int]
case class BooleanLit(b: Boolean) extends Expr[Boolean]
case class Sum(l: Expr[Int], r: Expr[Int]) extends Expr[Int]
case class Or(l: Expr[Boolean], r: Expr[Boolean]) extends Expr[Boolean]
def foo1a(x: Expr[Int]) = x match {
case _: IntLit => true
case _: Sum => true
}
def foo1b(x: Expr[Int]) = x match {
case _: Sum => true
}
def foo2a(x: Expr[Boolean]) = x match {
case _: BooleanLit => true
case _: Or => true
}
def foo2b(x: Expr[Boolean]) = x match {
case _: BooleanLit => true
}
def foo3a(x: Expr[Boolean]) = x match {
case _: BooleanLit => true
case _: Or => true
// case _: Sum => true
}
def foo3b(x: Expr[Int]) = x match {
case _: IntLit => true
case _: Sum => true
// case _: Or => true
}
def foo4a(x: Expr[_]) = x match {
case _: IntLit => true
case _: Sum => true
case _: BooleanLit => true
case _: Or => true
}
def foo4b(x: Expr[_]) = x match {
case _: Sum => true
case _: Or => true
}
def foo5a[T <: Int](x: Expr[T]) = x match {
case _: IntLit => true
case _: Sum => true
}
def foo5b[T <: Int](x: Expr[T]) = x match {
case _: IntLit => true
}
}
|