Add support for desctructuring of lambda parameters in JVM backend
#KT-5828 In Progress
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
class A<T>(val x: String, val y: String, val z: T)
|
||||
|
||||
fun <T> foo(a: A<T>, block: (A<T>) -> String): String = block(a)
|
||||
|
||||
operator fun A<*>.component1() = x
|
||||
|
||||
object B {
|
||||
operator fun A<*>.component2() = y
|
||||
}
|
||||
|
||||
fun B.bar(): String {
|
||||
|
||||
operator fun <R> A<R>.component3() = z
|
||||
|
||||
val x = foo(A("O", "K", 123)) { (x, y, z) -> x + y + z.toString() }
|
||||
if (x != "OK123") return "fail 1: $x"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun box() = B.bar()
|
||||
Reference in New Issue
Block a user