From d42f62bbd76df85ed57162118a8c720f50bbd5c5 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Fri, 6 Nov 2009 18:00:43 +0000 Subject: Fixed initial variable binding for method param... Fixed initial variable binding for method parameters, that caused the inliner to infer wrong types for tail recursive methods --- test/files/run/inliner-infer.check | 2 ++ test/files/run/inliner-infer.scala | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/files/run/inliner-infer.check create mode 100644 test/files/run/inliner-infer.scala (limited to 'test') 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 +} + + -- cgit v1.2.3