Initializer default values in 'tailrec' method in proper order

#KT-31540 Fixed
This commit is contained in:
Mikhael Bogdanov
2019-06-13 13:39:17 +02:00
parent 077092d619
commit c78dbaf6b3
20 changed files with 309 additions and 17 deletions
@@ -0,0 +1,17 @@
// !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)
}