summaryrefslogblamecommitdiff
path: root/test/files/run/caseclasses.scala
blob: 809bfb35111a5996fa3ff2e453daa42bad2bbff5 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                 

                                                  


                             

                                        
   
 





                                         
 





                                         
 
 
case class Foo(x: int)(y: int);

case class Bar;

object Test extends Application {
  import compat.Platform.IndexOutOfBoundsException

  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() caseElement 2
    throw new NullPointerException("duh")
  } catch {
    case x:IndexOutOfBoundsException =>
  }

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

}