4f6fe1d0ca
This commit addresses the following issues: * accessors didn't take into account their property's receiver type, which caused NoSuchMethod due to signature mismatch. Now the property's receiver type is passed to Fir2Ir translation of accessors. * property's parent was not class, e.g., kotlin.collections.indices. Now the symbol table collects WrappedPropertyDescriptorWithContainerSource besides WrappedFunctionDescriptorWithContainerSource, so that facade classes for such properties can be generated before codegen. * accessor's parent was not class. Now the containerSource of the property descriptor is passed to accessor descriptor.
24 lines
609 B
Kotlin
Vendored
24 lines
609 B
Kotlin
Vendored
// KJS_WITH_FULL_RUNTIME
|
|
// WITH_RUNTIME
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
inline fun <T> Array<out T>.indexOfLast(predicate: (T) -> Boolean): Int {
|
|
for (index in indices.reversed()) {
|
|
if (predicate(this[index])) {
|
|
return index
|
|
}
|
|
}
|
|
return -1
|
|
}
|
|
|
|
val ints = arrayOf(1, 2, 3, 2, 1)
|
|
|
|
fun box(): String {
|
|
assertEquals(-1, ints.indexOfLast { it == 4 })
|
|
assertEquals(4, ints.indexOfLast { it == 1 })
|
|
assertEquals(3, ints.indexOfLast { it == 2 })
|
|
assertEquals(2, ints.indexOfLast { it == 3 })
|
|
assertEquals(-1, ints.indexOfLast { it == 0 })
|
|
return "OK"
|
|
} |