All tests for TCO moved to box (with diagnostics marked up)
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
tailRecursive fun Int.foo(x: Int) {
|
||||
if (x == 0) return
|
||||
return 1.foo(x - 1)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
1.foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -1,3 +1,8 @@
|
||||
<!NO_TAIL_CALLS_FOUND!>tailRecursive fun noTails()<!> {
|
||||
// nothing here
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
noTails()
|
||||
return "OK"
|
||||
}
|
||||
+7
-2
@@ -1,12 +1,17 @@
|
||||
tailRecursive fun badTails(x : Int) : Int {
|
||||
if (x > 0) {
|
||||
if (x < 50 && x != 10 && x > 0) {
|
||||
return 1 + <!NON_TAIL_RECURSIVE_CALL!>badTails<!>(x - 1)
|
||||
}
|
||||
else if (x == 10) {
|
||||
[suppress("NON_TAIL_RECURSIVE_CALL")]
|
||||
return 1 + badTails(x - 1)
|
||||
} else if (x == 50) {
|
||||
} else if (x >= 50) {
|
||||
return badTails(x - 1)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
badTails(1000000)
|
||||
return "OK"
|
||||
}
|
||||
+6
@@ -3,4 +3,10 @@ fun withoutAnnotation(x : Int) : Int {
|
||||
return 1 + withoutAnnotation(x - 1)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val r = withoutAnnotation(10)
|
||||
if (r == 10) return "OK"
|
||||
return "Fail $r"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
tailRecursive fun Int.foo(x: Int) {
|
||||
if (x == 0) return
|
||||
val xx = x - 1
|
||||
return 1 foo xx
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
1 foo 1000000
|
||||
return "OK"
|
||||
}
|
||||
+6
-1
@@ -5,4 +5,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
fun run(a: Any) {}
|
||||
fun run(a: Any) {}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -2,4 +2,9 @@
|
||||
fun bar() {
|
||||
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo()
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
tailRecursive fun foo(x: Int) {
|
||||
if (x == 0) return
|
||||
(return foo(x - 1))
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
tailRecursive fun foo(x: Int) {
|
||||
return if (x > 0) {
|
||||
(foo(x - 1))
|
||||
}
|
||||
else Unit.VALUE
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
tailRecursive fun foo(x: Int) {
|
||||
if (x == 0) return
|
||||
return (foo(x - 1))
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
foo(1000000)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<!NO_TAIL_CALLS_FOUND!>tailRecursive fun test(go: Boolean) : Unit<!> {
|
||||
if (!go) return
|
||||
try {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(false)
|
||||
} catch (any : Exception) {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(false)
|
||||
} finally {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>(false)
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(true)
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
tailRecursive fun Int.foo(x: Int) {
|
||||
return 1.foo(2)
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
tailRecursive fun Int.foo(x: Int) {
|
||||
return 1 foo 2
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
tailRecursive fun foo() {
|
||||
(return foo())
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
tailRecursive fun foo() {
|
||||
return if (true) {
|
||||
(foo())
|
||||
}
|
||||
else Unit.VALUE
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
tailRecursive fun foo() {
|
||||
return (foo())
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<!NO_TAIL_CALLS_FOUND!>tailRecursive fun test() : Unit<!> {
|
||||
try {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>()
|
||||
} catch (any : Exception) {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>()
|
||||
} finally {
|
||||
<!TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED!>test<!>()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user