[FIR2IR] Keep redundant cast on 'this' for local anonymous function

#KT-42517 Fixed
This commit is contained in:
Juan Chen
2020-10-21 05:02:11 +00:00
committed by Mikhail Glukhikh
parent f4531b0f34
commit 620a5d404d
9 changed files with 62 additions and 3 deletions
+19
View File
@@ -0,0 +1,19 @@
// WITH_RUNTIME
// FULL_JDK
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS
fun Any.copyValueIfNeeded(): Any {
return when (this) {
is Array<*> -> java.lang.reflect.Array.newInstance(this::class.java.componentType, size).apply {
this as Array<Any?>
(this@copyValueIfNeeded as Array<Any?>).forEachIndexed { i, value -> this[i] = value?.copyValueIfNeeded() }
}
else -> this
}
}
fun box(): String {
val res = arrayOf("FAIL", "OK").copyValueIfNeeded() as Array<String>
return res[1]
}