diff options
author | Paul Phillips <paulp@improving.org> | 2012-02-28 15:34:01 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-02-28 15:34:01 -0800 |
commit | 872c825192b30faa1b20f9cc2b1e3a0adeed8617 (patch) | |
tree | 17ec63094bbf9dd56d45aee4e4add0c784ecc4c1 /test/files/run | |
parent | 4ab3600298de995e7de6d5cfdce73e0f278341e2 (diff) | |
parent | 01ee3de96dcae707fb8fee28e93af0515519c603 (diff) | |
download | scala-872c825192b30faa1b20f9cc2b1e3a0adeed8617.tar.gz scala-872c825192b30faa1b20f9cc2b1e3a0adeed8617.tar.bz2 scala-872c825192b30faa1b20f9cc2b1e3a0adeed8617.zip |
Merge remote-tracking branch 'szabolcsberecz/SI-64' into SI-64-fresh
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/tailcalls.check | 1 | ||||
-rw-r--r-- | test/files/run/tailcalls.scala | 13 |
2 files changed, 10 insertions, 4 deletions
diff --git a/test/files/run/tailcalls.check b/test/files/run/tailcalls.check index 7670962db2..e3a70f46ae 100644 --- a/test/files/run/tailcalls.check +++ b/test/files/run/tailcalls.check @@ -43,6 +43,7 @@ test TailCall.g1 was successful test TailCall.g2 was successful test TailCall.g3 was successful test TailCall.h1 was successful +test TailCall.s1 was successful test NonTailCall.f1 0 1 2 was successful test NonTailCall.f2 was successful diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala index 04a1a8ba19..4cf6dd46d3 100644 --- a/test/files/run/tailcalls.scala +++ b/test/files/run/tailcalls.scala @@ -182,6 +182,8 @@ class TailCall[S](s: S) { def h1(n: Int, v: Int): Int = hP(n, v); private def hP(n: Int, v: Int): Int = if (n == 0) v else hP(n - 1, v - 1); + final def s1(n: Int, v: Int): Int = synchronized { if (n == 0) v else s1(n - 1, v - 1) } + // !!! test return in non-tail-call position // !!! test non-same-instance calls // !!! test non-same-type calls @@ -229,11 +231,13 @@ class NonTailCall { Console.print(" " + n) } - final def f2(n: Int): Int = synchronized { - if (n == 0) 0 - else f2(n - 1) + final def f2(n: Int): Int = { + val next = n - 1 + synchronized { + if (n == 0) 0 + else f2(next) + } } - } //############################################################################ @@ -366,6 +370,7 @@ object Test { check_success("TailCall.g2", TailCall.g2(max, max ), 0) check_success("TailCall.g3", TailCall.g3(max, max, Nil), 0) check_success("TailCall.h1", TailCall.h1(max, max ), 0) + check_success("TailCall.s1", TailCall.s1(max, max ), 0) println val NonTailCall = new NonTailCall |