Files
kotlin-fork/compiler/testData/codegen/box/defaultArguments/kt36853_nestedObject.kt
T
pyos 7c63d50d1c IR: create more temporary vals when optimizing tailrec calls
This is needed so that SharedVariablesLowering doesn't get confused, and
SharedVariablesLowering should run after TailrecLowering to properly
optimize tailrec calls in inline lambdas.
2021-10-01 14:37:54 +02:00

32 lines
645 B
Kotlin
Vendored

interface IFoo {
fun foo(): String
}
tailrec fun tailrecDefault(
fake: Int,
x: IFoo = object : IFoo {
tailrec fun tailrecDefaultNested(
b: Boolean,
y: IFoo = object: IFoo {
override fun foo() = "OK"
}
): String {
return if (b)
tailrecDefaultNested(false)
else
y.foo()
}
override fun foo(): String {
return tailrecDefaultNested(true)
}
}
): String {
return if (fake == 0)
tailrecDefault(1)
else
x.foo()
}
fun box(): String = tailrecDefault(0)