aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/typers.scala
blob: 3fcd1ff29a74930873e9edd7c98d8b17f44a56cd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
object typers {
  
  class List[+T] {
    def :: (x: T) = new :: (x, this)
    
    def len: Int = this match {
      case x :: xs1 => 1 + xs1.len
      case Nil => 0
    }
  }
  
  object Nil extends List[Nothing]
  
  case class :: [+T] (hd: T, tl: List[T]) extends List[T]
  
  def len[U](xs: List[U]): Int = xs match {
    case x :: xs1 => 1 + len(xs1)
    case Nil => 0
  }

}