aboutsummaryrefslogblamecommitdiff
path: root/tests/pos/tailcall/tailcall.scala
blob: faa707e18186d268f4965588c6556beb981a1398 (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                                                           


                                                                              
 
class tailcall {
  val shift = 1
  final def fact(x: Int, acc: Int = 1): Int = if (x == 0) acc else fact(x - shift, acc * x)
  def id[T <: AnyRef](x: T): T = if (x eq null) x else id(x)
}

class TypedApply[T2]{
  private def firstDiff[T <: TypedApply[T2]](xs: List[T]): Int = firstDiff(xs)
}