Files
kotlin-fork/compiler/testData/diagnostics/tests/tailRecursionComplex.kt
T
Tianyu Geng 8525b4932b FIR Checker: check tailrec
Difference from FE1.0
* KT-4285: calls to virtual method with default argument should be
  reported as not tailrec. FE1.0 is missing such cases.
* KT-48600: calls inside lambda should be reported as not tailrec. FE1.0
  also misses such cases.
2021-09-14 23:48:50 +03:00

16 lines
445 B
Kotlin
Vendored

object O {
// foo is the same, but the compiler currently doesn't compile this as tail recursive. See KT-48602
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)
}