Fix code generation for Array<C> element access where C is inline class

This commit is contained in:
Dmitry Petrov
2018-08-10 14:22:41 +03:00
parent 8063db5f80
commit 0af33462ef
10 changed files with 226 additions and 8 deletions
@@ -0,0 +1,14 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR, JS_IR
inline class Z(val data: Int)
val xs = Array(2) { Z(42) }
fun box(): String {
xs[0] = Z(12)
val t = xs[0]
if (t.data != 12) throw AssertionError("$t")
return "OK"
}
@@ -0,0 +1,12 @@
// WITH_UNSIGNED
// IGNORE_BACKEND: JVM_IR, JS_IR, JS
val xs = Array(2) { 42u }
fun box(): String {
xs[0] = 12u
val t = xs[0]
if (t != 12u) throw AssertionError("$t")
return "OK"
}
@@ -0,0 +1,23 @@
// !LANGUAGE: +InlineClasses
// WITH_UNSIGNED
// IGNORE_BACKEND: JVM_IR, JS_IR, JS
inline class Data(val data: Array<UInt>)
val D =
Array(4) { i ->
Data(Array(4) { j ->
(i + j).toUInt()
})
}
fun box(): String {
for (i in D.indices) {
for (j in D[i].data.indices) {
val x = D[i].data[j].toInt()
if (x != i + j) throw AssertionError()
}
}
return "OK"
}