Correct boxing for functional types containing inline classes

This commit is contained in:
Mikhail Zarechenskiy
2018-02-09 08:48:15 +03:00
parent a8a9f774d0
commit d606e5bc89
10 changed files with 111 additions and 1 deletions
@@ -0,0 +1,27 @@
// !LANGUAGE: +InlineClasses
inline class UInt(val value: Int)
inline class ULong(val value: Long)
fun foo(u: UInt, f: (UInt) -> ULong): ULong = f(u)
fun takeUInt(u: UInt) {}
fun test() {
val u = UInt(0)
val l = foo(u) { // box unbox UInt
takeUInt(it)
ULong(0) // box ULong
} // unbox ULong
}
// 1 INVOKESTATIC UInt\$Erased.box
// 1 INVOKEVIRTUAL UInt.unbox
// 1 INVOKESTATIC ULong\$Erased.box
// 1 INVOKEVIRTUAL ULong.unbox
// 0 valueOf
// 0 intValue
// 0 longValue