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

33 lines
653 B
Kotlin
Vendored

// See also KT-4285
open class A {
open fun foo(x: Int = 0) {}
open fun gav(y: Int = 1, z: Int = 2) {}
}
class B: A() {
<!NO_TAIL_CALLS_FOUND!>tailrec override fun foo(x: Int)<!> {
<!NON_TAIL_RECURSIVE_CALL!>foo<!>()
}
<!NO_TAIL_CALLS_FOUND!>tailrec override fun gav(y: Int, z: Int)<!> {
<!NON_TAIL_RECURSIVE_CALL!>gav<!>(y)
}
tailrec fun bar(y: Double): Double = bar(y * 2.0)
}
class C: A() {
tailrec override fun foo(x: Int) {
foo(0)
}
tailrec override fun gav(y: Int, z: Int) {
gav(y - 1, z - 1)
}
tailrec fun bar(y: Int = 1, z: Int = 2) {
bar(z)
}
}