8525b4932b
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.
20 lines
518 B
Kotlin
Vendored
20 lines
518 B
Kotlin
Vendored
// KT-14961
|
|
// IGNORE_BACKEND: JVM, JS_IR, WASM
|
|
// WITH_RUNTIME
|
|
// IGNORE_FIR_DIAGNOSTICS_DIFF
|
|
|
|
fun listOfFactor(number: Int): List<Int> {
|
|
tailrec fun listOfFactor(number: Int, acc: List<Int>): List<Int> {
|
|
(2..number).forEach {
|
|
if (number % it == 0) return listOfFactor(number / it, acc + it)
|
|
}
|
|
return acc
|
|
}
|
|
return listOfFactor(number, emptyList())
|
|
}
|
|
|
|
fun box(): String {
|
|
val factors = listOfFactor(60)
|
|
return if (factors.size == 4) "OK" else "Fail: $factors"
|
|
}
|