Iterate Intention: Add support of destructuring declarations

This commit is contained in:
Alexey Sedunov
2015-12-17 21:30:14 +03:00
parent 1d3054e7a6
commit ae636a0d32
10 changed files with 158 additions and 56 deletions
@@ -0,0 +1,10 @@
// WITH_RUNTIME
class Foo(val id: Int, val name: String)
operator fun Foo.component1() = id
operator fun Foo.component2() = name
operator fun Foo.component3() = "$name: $id"
fun test() {
listOf(Foo(123, "def"), Foo(456, "abc"))<caret>
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
class Foo(val id: Int, val name: String)
operator fun Foo.component1() = id
operator fun Foo.component2() = name
operator fun Foo.component3() = "$name: $id"
fun test() {
for ((i, s, s1) in listOf(Foo(123, "def"), Foo(456, "abc"))) {
<caret>
}
}
@@ -0,0 +1,6 @@
// WITH_RUNTIME
data class Foo(val id: Int, val name: String)
fun test() {
listOf(Foo(123, "def"), Foo(456, "abc"))<caret>
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
data class Foo(val id: Int, val name: String)
fun test() {
for ((id, name) in listOf(Foo(123, "def"), Foo(456, "abc"))) {
<caret>
}
}
@@ -1,6 +1,6 @@
// WITH_RUNTIME
fun test() {
for (entry in mapOf(1 to "1", 2 to "2")) {
for ((i, s) in mapOf(1 to "1", 2 to "2")) {
<caret>
}
}