KT-13241 Indices optimization leads to VerifyError with smart cast receiver

Use expected receiver type from the corresponding extension function.
This commit is contained in:
Dmitry Petrov
2016-07-27 11:29:02 +03:00
parent f3be1b8f1f
commit 26c8bc87fd
5 changed files with 101 additions and 42 deletions
@@ -0,0 +1,18 @@
// WITH_RUNTIME
import kotlin.test.assertEquals
fun test(x: Any): Int {
var sum = 0
if (x is IntArray) {
for (i in x.indices) {
sum = sum * 10 + i
}
}
return sum
}
fun box(): String {
assertEquals(123, test(intArrayOf(0, 0, 0, 0)))
return "OK"
}
@@ -0,0 +1,18 @@
// WITH_RUNTIME
import kotlin.test.assertEquals
fun test(x: Any): Int {
var sum = 0
if (x is String) {
for (i in x.indices) {
sum = sum * 10 + i
}
}
return sum
}
fun box(): String {
assertEquals(123, test("0000"))
return "OK"
}
@@ -0,0 +1,18 @@
// WITH_RUNTIME
import kotlin.test.assertEquals
fun test(x: Any): Int {
var sum = 0
if (x is List<*>) {
for (i in x.indices) {
sum = sum * 10 + i
}
}
return sum
}
fun box(): String {
assertEquals(123, test(listOf(0, 0, 0, 0)))
return "OK"
}