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:
+22
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user