16
16
def ex3[T](xx: (Foo[T], Foo[T])) = xx match {
17
17
case (_: Foo[_], _: Foo[_]) => ()
20
// fails for: ::(_, ::(_, ::(_, _)))
20
21
def fail1[T](xs: List[T]) = xs match {
22
23
case x :: y :: Nil => "ok"
24
27
def fail2[T](xs: List[T]) = xs match {
25
28
case _ :: _ => "ok"
31
// fails for: ::(<not in (2, 1)>, _)
32
def fail3a(xs: List[Int]) = xs match {
27
39
def fail3[T](x: Foo[T]) = x match {
43
// fails for: (Bar1, Bar2)
44
// fails for: (Bar1, Bar3)
45
// fails for: (Bar2, Bar2)
46
// fails for: (Bar2, Bar1)
31
47
def fail4[T <: AnyRef](xx: (Foo[T], Foo[T])) = xx match {
32
48
case (Bar1, Bar1) => ()
33
49
case (Bar2, Bar3) => ()
34
50
case (Bar3, _) => ()
52
// fails for: (Bar1, Bar2)
53
// fails for: (Bar1, Bar3)
54
// fails for: (Bar2, Bar1)
55
// fails for: (Bar2, Bar2)
36
56
def fail5[T](xx: (Foo[T], Foo[T])) = xx match {
37
57
case (Bar1, Bar1) => ()
38
58
case (Bar2, Bar3) => ()
39
59
case (Bar3, _) => ()
42
def main(args: Array[String]): Unit = {