Files
kotlin-fork/compiler/fir/psi2fir/testData/rawBuilder/expressions/lambda.kt
T
Mikhail Glukhikh db2fb86c8e Raw FIR: implement expression trees & conversions from PSI
Testing: total kotlin test controls no stubs in FIR in non-stub-mode
#KT-29002 Fixed
2019-02-06 11:58:59 +03:00

29 lines
562 B
Kotlin
Vendored

data class Tuple(val x: Int, val y: Int)
inline fun use(f: (Tuple) -> Int) = f(Tuple(1, 2))
fun foo(): Int {
val l1 = { t: Tuple ->
val x = t.x
val y = t.y
x + y
}
use { (x, y) -> x + y }
return use {
if (it.x == 0) return@foo 0
return@use it.y
}
}
fun bar(): Int {
return use lambda@{
if (it.x == 0) return@bar 0
return@lambda it.y
}
}
fun test(list: List<Int>) {
val map = mutableMapOf<Int, String>()
list.forEach { map.getOrPut(it, { mutableListOf() }) += "" }
}