// IGNORE_BACKEND: JS // WITH_RUNTIME // NO_CHECK_LAMBDA_INLINING // FILE: 1.kt // KJS_WITH_FULL_RUNTIME package test public inline fun T.myalso(block: (T) -> Unit): T { block(this) return this } public inline fun Iterable.mymapNotNull(transform: (T) -> R?): List { return mapNotNullTo(ArrayList(), 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) }