KT-53465, KT-53677 Get rid of unnecessary checkcasts to array of reified type

This commit is contained in:
Pavel Mikhailovskii
2022-09-06 11:12:42 +02:00
committed by teamcity
parent d8522a8967
commit a75d5ba4cf
17 changed files with 213 additions and 1 deletions
@@ -0,0 +1,15 @@
// TARGET_BACKEND: JVM_IR
public inline fun <reified T> myEmptyArray(): Array<T> = arrayOfNulls<T>(0) as Array<T>
inline fun <reified T> Array<out T>?.myOrEmpty(): Array<out T> = this ?: myEmptyArray<T>()
fun foo(a : Array<String>?) = a.myOrEmpty()
val a = arrayOf<Int>(1) as Array<Any>
val b = arrayOf<Int>(1) as Array<Int>
val c = arrayOf(arrayOf<Int>(1)) as Array<Array<Any>?>
// 0 CHECKCAST