Files
kotlin-fork/compiler/testData/codegen/box/callableReference/function/extensionProperty.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

23 lines
692 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
import kotlin.reflect.KClass
fun box(): String {
val arr: Array<KClass<*>> = arrayOf(String::class, Number::class) as Array<KClass<*>>
val xs = arr.myMap { it.java }.toList()
val ys = arr.myMap(KClass<*>::java).toList()
if (xs != ys) return "fail1"
if (!arr.foo()) return "fail2"
return "OK"
}
public inline fun <A, B> Array<out A>.myMap(transform: (A) -> B): List<B> {
return mapTo(ArrayList<B>(size), transform)
}
fun Any?.foo(): Boolean {
val result = (this as Array<KClass<*>>).map(KClass<*>::java).toList()
val withLambda = (this as Array<KClass<*>>).map { it.java }.toList()
return result == withLambda
}