aboutsummaryrefslogtreecommitdiff
path: root/tests/run/inliner-infer.scala
blob: 6a2e47194dc5a840f453dac2dfa5d6ce2bef4919 (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
/** Test that the inliner is not inferring that `xs' is
 *  always Nil, removing the call to isEmpty.
 */
object Test extends dotty.runtime.LegacyApp {

  @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
}