summaryrefslogtreecommitdiff
path: root/test/files/run/caseclasses.scala
blob: 72a7232d8ace2b0636ede7a2e7691afa456d131b (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
case class Foo(x: int)(y: int);

case class Bar;

object Test extends Application {

  def fn[a,b](x: a => b) = x;
  val f = fn(Foo(1))
  (f(2): AnyRef) match {
    case Foo(1) => Console.println("OK")
    case Bar() => Console.println("NO")
  }

  try {
    Bar() productElement 3
    throw new NullPointerException("duh")
  } catch {
    case x:IndexOutOfBoundsException =>
  }

  try {
    f(2) productElement 3
    throw new NullPointerException("duh")
  } catch {
    case x:IndexOutOfBoundsException =>
  }

}