Files
kotlin-fork/compiler/testData/codegen/boxInline/callableReference/kt15751_2.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

40 lines
772 B
Kotlin
Vendored

// IGNORE_BACKEND: JS
// WITH_STDLIB
// NO_CHECK_LAMBDA_INLINING
// KJS_WITH_FULL_RUNTIME
// FILE: 1.kt
package test
public inline fun <T> T.myalso(block: (T) -> Unit): T {
block(this)
return this
}
public inline fun <T, R : Any> Iterable<T>.mymapNotNull(transform: (T) -> R?): List<R> {
return mapNotNullTo(ArrayList<R>(), transform)
}
// FILE: 2.kt
import test.*
var result = -1;
fun box(): String {
fff()
return if (result == 1) "OK" else "fail $result"
}
fun fff(): Int {
val y = 0
return 0.myalso {
fun increase(x: Int): Int = x + y
val values = listOf(1).mymapNotNull { something(::increase, it) }
result = values[0]!!
}
}
fun something(increase: (Int) -> Int, x: Int): Int? {
return increase(x)
}