diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/inliner-infer.check | 2 | ||||
-rw-r--r-- | test/files/run/inliner-infer.scala | 29 |
2 files changed, 31 insertions, 0 deletions
diff --git a/test/files/run/inliner-infer.check b/test/files/run/inliner-infer.check new file mode 100644 index 0000000000..d702bd602d --- /dev/null +++ b/test/files/run/inliner-infer.check @@ -0,0 +1,2 @@ +non-empty +empty diff --git a/test/files/run/inliner-infer.scala b/test/files/run/inliner-infer.scala new file mode 100644 index 0000000000..107b9508ee --- /dev/null +++ b/test/files/run/inliner-infer.scala @@ -0,0 +1,29 @@ + + +/** Test that the inliner is not inferring that `xs' is + * always Nil, removing the call to isEmpty. + */ +object Test extends Application { + + @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 +} + + |