Keep track of array types in OptimizationBasicInterpreter

Merging array types with different element types, for example
`[Lj/l/String;` and `[Lj/l/Object;`, now produces `[Lj/l/Object;`
(instead of `Lj/l/Object;`), which allows for more precise tracking of
null values because we assume that AALOAD on a non-array typed value is
possible only if that value is null.

 #KT-54802 Fixed
This commit is contained in:
Alexander Udalov
2022-11-05 12:12:33 +01:00
parent a79927742c
commit d7a58a7c6c
11 changed files with 105 additions and 20 deletions
-4
View File
@@ -1,6 +1,3 @@
// IGNORE_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
fun box(): String =
g(arrayOf("O"))
@@ -12,4 +9,3 @@ inline fun <T> Array<out T>.f(lambda: (T) -> T): T =
inline fun <reified T> Array<out T>?.orEmpty0(): Array<out T> =
this ?: (arrayOfNulls<T>(0) as Array<T>)
+14
View File
@@ -0,0 +1,14 @@
class K {
val x: String = "OK"
}
inline fun <T> Array<out T>.ifEmpty(body: () -> Array<out T>): Array<out T> =
if (size == 0) body() else this
inline fun <T> Array<out T>.f(p: (T) -> String): String =
p(this[0])
fun box(): String =
emptyArray<K>()
.ifEmpty { arrayOf(K()) }
.f(K::x)