Detecting tail calls through CFA

This commit is contained in:
Andrey Breslav
2013-12-06 00:00:01 +04:00
parent 9f319e8b24
commit 97319808b6
16 changed files with 483 additions and 7 deletions
@@ -0,0 +1,10 @@
tailRecursive fun sum(x: Long, sum: Long): Long {
if (x == 0.toLong()) return sum
return sum(x - 1, sum + x)
}
fun box() : String {
val sum = sum(1000000, 0)
if (sum != 500000500000.toLong()) return "Fail $sum"
return "OK"
}