Files
kotlin-fork/compiler/testData/codegen/box/defaultArguments/useNextParamInLambdaTailrec.kt
T
pyos cb505d1101 IR: keep capture sets the same when copying objects for tailrec funs
tailrec f(x: () -> T = { y }, y: T = ...) = f()

-- at the call we know that in `x` the observed value of `y` is `null`,
but the constructor should still have a single parameter.
2021-10-01 14:37:54 +02:00

10 lines
224 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
tailrec fun foo(x: () -> String? = { y }, y: String = "fail"): String? {
if (y == "start")
return foo()
return x()
}
fun box() = foo(y = "start") ?: "OK"