Files
kotlin-fork/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt
T
2019-10-17 13:06:36 +02:00

17 lines
415 B
Kotlin
Vendored

// !LANGUAGE: -ProperComputationOrderOfTailrecDefaultParameters
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
var counter = 0
fun calc(counter: Int) = if (counter % 2 == 0) "K" else "O"
<!TAILREC_WITH_DEFAULTS!>tailrec fun test(x: Int, y: String = calc(counter++), z: String = calc(counter++)): String<!> {
if (x > 0)
return y + z
return test(x + 1)
}
fun box(): String {
return test(0)
}