Properly generate indices for destructured parameters in inline case
#KT-14399 Fixed
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
data class Station(
|
||||
val id: String?,
|
||||
val name: String,
|
||||
val distance: Int)
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
// See KT-14399
|
||||
listOf(Station("O", "K", 56)).forEachIndexed { i, (id, name, distance) -> result += "$id$name$distance" }
|
||||
if (result != "OK56") return "fail: $result"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun foo(x: (Int, Station) -> Unit) {
|
||||
x(1, Station(null, "", 1))
|
||||
}
|
||||
|
||||
data class Station(
|
||||
val id: String?,
|
||||
val name: String,
|
||||
val distance: Int)
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
foo { i, (a1, a2, a3) -> i + a3 }
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// for android
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
var res = "fail"
|
||||
|
||||
inline fun foo(x: (Int, Station) -> Unit) {
|
||||
x(1, Station("a", "b", "c"))
|
||||
res = "O"
|
||||
}
|
||||
|
||||
inline fun foo2(x: (Int, StationInt) -> Unit) {
|
||||
x(1, StationInt(1, 2, 3))
|
||||
res += "K"
|
||||
}
|
||||
|
||||
data class Station(
|
||||
val id: String,
|
||||
val name: String,
|
||||
val distance: String)
|
||||
|
||||
data class StationInt(
|
||||
val id: Int,
|
||||
val name: Int,
|
||||
val distance: Int)
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
foo { i, (a1, a2, a3) -> a3 + i }
|
||||
foo2 { i, (a1, a2, a3) -> i + a3 }
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user