Files
kotlin-fork/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt
T
2019-11-19 11:00:09 +03:00

18 lines
445 B
Kotlin
Vendored

// !LANGUAGE: -ProperComputationOrderOfTailrecDefaultParameters
// IGNORE_BACKEND_FIR: JVM_IR
// 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)
}