summaryrefslogblamecommitdiff
path: root/test/files/run/inliner-infer.scala
blob: ea83966c522172dba24d13726eba3650a55f611a (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                       
                         


                                

                       
















                             
  
/** Test that the inliner is not inferring that `xs' is
 *  always Nil, removing the call to isEmpty.
 */
object Test extends App {

  @annotation.tailrec
  def walk(xs: MyList): Unit = {
    if (xs.isEmpty) 
      println("empty") 
    else {
      println("non-empty")
      walk(MyNil)
    }
  }

  walk(new MyList)
}

class MyList {
  def isEmpty = false
}

object MyNil extends MyList {
  override def isEmpty = true
}