Files
kotlin-fork/compiler/testData/codegen/box/diagnostics/functions/tailRecursion/thisReferences.kt
T
Tianyu Geng 5252effb10 FIR checker: report tailrec problems on the keyword
FE1.0 reports it on the declaration signature. This is not ideal so we
move it to the `tailrec` keyword in FIR.
2021-09-28 22:30:09 +03:00

32 lines
732 B
Kotlin
Vendored

// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: IGNORED_IN_JS
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// TODO: muted automatically, investigate should it be ran for JS or not
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JS
class A {
tailrec fun f1(c : Int) {
if (c > 0) {
this.f1(c - 1)
}
}
tailrec fun f2(c : Int) {
if (c > 0) {
f2(c - 1)
}
}
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun f3(a : A) {
a.<!NON_TAIL_RECURSIVE_CALL!>f3<!>(a) // non-tail recursion, could be potentially resolved by condition if (a == this) f3() else a.f3()
}
}
fun box() : String {
A().f1(1000000)
A().f2(1000000)
return "OK"
}