Files
kotlin-fork/compiler/testData/diagnostics/tests/tailRecursionComplex.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

18 lines
399 B
Kotlin
Vendored

// FIR_IDENTICAL
object O {
// tailrec since `O` is a singleton
tailrec fun foo(i: Int): Int = if (i < 0) 0 else O.foo(i - 1)
}
class A {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo(i: Int) = if (i < 0) 0 else A.foo(i - 1)
companion object {
fun foo(i: Int) = 42 + i
}
}
class B {
<!NO_TAIL_CALLS_FOUND!>tailrec<!> fun foo(i: Int) = if (i < 0) 0 else O.foo(i - 1)
}