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
@@ -1,5 +1,5 @@
// !LANGUAGE: +ProperComputationOrderOfTailrecDefaultParameters
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JVM
var counter = 0
fun inc() = counter++
@@ -1,3 +1,5 @@
// !LANGUAGE: +ProperComputationOrderOfTailrecDefaultParameters
// Flag above doesn't matter cause 1 default value is passed explicitly in tail recursion call
// DONT_RUN_GENERATED_CODE: JS
var counter = 0
@@ -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)
}
@@ -0,0 +1,6 @@
package
public var counter: kotlin.Int
public fun box(): kotlin.String
public fun calc(/*0*/ counter: kotlin.Int): kotlin.String
public tailrec fun test(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): kotlin.String