Support boxing/unboxing for captured vars of inline class types

This commit is contained in:
Mikhail Zarechenskiy
2018-02-07 04:49:06 +03:00
parent 9f24bbd980
commit fefcddc803
14 changed files with 228 additions and 79 deletions
@@ -0,0 +1,31 @@
// !LANGUAGE: +InlineClasses
inline class UInt(val value: Int)
fun test(x: UInt?) {
x?.myLet { // unbox
takeUInt(it)
takeUInt(x) // unbox
}
x?.myLet { // unbox
takeNullableUInt(it) // box
takeNullableUInt(x)
}
x!!.myLet { // unbox
takeUInt(it)
takeUInt(x) // unbox
}
}
fun takeUInt(y: UInt) {}
fun takeNullableUInt(y: UInt?) {}
inline fun <T> T.myLet(f: (T) -> Unit) = f(this)
// 1 INVOKESTATIC UInt\$Erased.box
// 5 INVOKEVIRTUAL UInt.unbox
// 0 intValue
// 0 valueOf