Files
kotlin/compiler/testData/codegen/box/inlineClasses/unboxValueOfAnyBeforeMethodInvocation.kt
Mikhail Zarechenskiy a8abd8cceb 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
2018-10-12 11:58:56 +03:00

23 lines
525 B
Kotlin
Vendored

// 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"
}