KT-12983 java.lang.VerifyError: Bad type on operand stack in arraylength

Use proper receiver value type.
This commit is contained in:
Dmitry Petrov
2016-07-05 14:57:28 +03:00
parent 6b8e8cee17
commit 3dc23a0e02
6 changed files with 114 additions and 1 deletions
@@ -0,0 +1,22 @@
// WITH_RUNTIME
abstract class BaseGeneric<T>(val t: T) {
abstract fun iterate()
}
class Derived<T>(array: Array<T>) : BaseGeneric<Array<T>>(array) {
var test = 0
override fun iterate() {
test = 0
for (i in t.indices) {
test = test * 10 + (i + 1)
}
}
}
fun box(): String {
val t = Derived(arrayOf("", "", "", ""))
t.iterate()
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
}
@@ -0,0 +1,22 @@
// WITH_RUNTIME
abstract class BaseGeneric<T>(val t: T) {
abstract fun iterate()
}
class Derived<T>(t: List<T>) : BaseGeneric<List<T>>(t) {
var test = 0
override fun iterate() {
test = 0
for (i in t.indices) {
test = test * 10 + (i + 1)
}
}
}
fun box(): String {
val t = Derived(listOf("", "", "", ""))
t.iterate()
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
}
@@ -0,0 +1,22 @@
// WITH_RUNTIME
abstract class BaseGeneric<T>(val t: T) {
abstract fun iterate()
}
class Derived(array: DoubleArray) : BaseGeneric<DoubleArray>(array) {
var test = 0
override fun iterate() {
test = 0
for (i in t.indices) {
test = test * 10 + (i + 1)
}
}
}
fun box(): String {
val t = Derived(doubleArrayOf(0.0, 0.0, 0.0, 0.0))
t.iterate()
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
}
@@ -0,0 +1,22 @@
// WITH_RUNTIME
abstract class BaseGeneric<T>(val t: T) {
abstract fun iterate()
}
class Derived(t: List<Int>) : BaseGeneric<List<Int>>(t) {
var test = 0
override fun iterate() {
test = 0
for (i in t.indices) {
test = test * 10 + (i + 1)
}
}
}
fun box(): String {
val t = Derived(listOf(1, 2, 3, 4))
t.iterate()
return if (t.test == 1234) "OK" else "Fail: ${t.test}"
}