summaryrefslogtreecommitdiff
path: root/test/files/run/mics1.scala
blob: b3673dd5e0086389447a6e7f8a2f460d9d96d89c (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
abstract class IntMap[a] {
    def lookup(key: Int): a = match {
        case Empty() => error("key " + key + " not found")
        case _ => error("ok")
    }
}

case class Empty[a]() extends IntMap[a];

object Test {

    def main(args: Array[String]): Unit = {
        val key = 2000;
        val map: IntMap[String] = new Empty[String];

        System.out.print("lookup(" + key + ") = ");
        try {
            System.out.println(map.lookup(key));
        } catch {
            case e => System.out.println(e.getMessage());
        }
    }

}