blob: 7266dabe6df4471e40afeb78409eb40f898d7f48 (
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
|
object Test {
trait Immortal
class Bippy extends Immutable with Immortal
class Boppy extends Immutable
def f[T](x: Traversable[T]) = x match {
case _: Map[_, _] => 3
case _: Seq[_] => 2
case _: Iterable[_] => 1
case _ => 4
}
def g(x: Bippy) = x match {
case _: Immutable with Immortal => 1
case _ => 2
}
def h(x: Immutable) = x match {
case _: Immortal => 1
case _ => 2
}
def main(args: Array[String]): Unit = {
println(f(Set(1)))
println(f(Seq(1)))
println(f(Map(1 -> 2)))
println(f(null))
println(g(new Bippy))
println(g(null))
println(h(new Bippy))
println(h(new Boppy))
println(h(null))
}
}
|