Files
kotlin/compiler/testData/codegen/box/reflection/mapping/inlineClassPrimaryVal.kt
Dmitry Petrov 99d8f2eb0c Support 'call' for primary value of an inline class
Getter of a primary value of an inline class belongs to the box class.
Its arguments should not be unboxed when the method is called.
However, its result might require boxing if it's an inline class value.

When we have an internal primary value, there's no getter method.
In fact, we can use box/unbox methods for inline class directly
(don't forget to box the result, it may be an inline class type value).

 #KT-26748
2018-11-14 09:57:51 +03:00

39 lines
993 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE
// WITH_REFLECT
import kotlin.reflect.jvm.*
import kotlin.test.assertEquals
inline class Z1(val publicX: Int) {
companion object {
val publicXRef = Z1::publicX
val publicXBoundRef = Z1(42)::publicX
}
}
inline class Z2(internal val internalX: Int) {
companion object {
val internalXRef = Z2::internalX
val internalXBoundRef = Z2(42)::internalX
}
}
inline class Z3(private val privateX: Int) {
companion object {
val privateXRef = Z3::privateX
val privateXBoundRef = Z3(42)::privateX
}
}
fun box(): String {
assertEquals("getPublicX", Z1.publicXRef.javaGetter!!.name)
assertEquals("getPublicX", Z1.publicXBoundRef.javaGetter!!.name)
assertEquals(null, Z2.internalXRef.javaGetter)
assertEquals(null, Z2.internalXBoundRef.javaGetter)
assertEquals(null, Z3.privateXRef.javaGetter)
assertEquals(null, Z3.privateXBoundRef.javaGetter)
return "OK"
}