Fix boxing/unboxing for generic functions on index expressions

Unsubstituted type should be used for coercion to box value of
 inline class type if it's needed. For the substituted value it's not
 known if it was a generic parameter or not.

 #KT-27502 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2018-10-11 11:02:00 +03:00
parent 882a12d916
commit a8abd8cceb
8 changed files with 50 additions and 13 deletions
@@ -0,0 +1,22 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM_IR
inline class NullableInt(private val holder: Any?) {
val intValue: Int get() = holder as Int
}
val prop: ArrayList<NullableInt> = arrayListOf(NullableInt(0))
fun box(): String {
val a = prop[0].intValue
if (a != 0) return "Error 1: $a"
val local = mutableListOf(NullableInt(1))
val b = local[0].intValue
if (b != 1) return "Error 2: $b"
prop[0] = NullableInt(2)
if (prop[0].intValue != 2) return "Error 3: ${prop[0].intValue}"
return "OK"
}