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,26 @@
// !LANGUAGE: +InlineClasses
inline class UInt(val value: Int)
inline class ULong(val value: Long)
fun foo(u: UInt, f: (UInt) -> ULong): ULong = f(u)
inline fun inlinedFoo(u: UInt, f: (UInt) -> ULong): ULong = f(u)
fun mapUIntToULong(u: UInt): ULong = ULong(u.value.toLong())
fun box(): String {
val u = UInt(123)
val l1 = foo(u) {
mapUIntToULong(it)
}
if (l1.value != 123L) return "fail"
val l2 = inlinedFoo(UInt(10)) {
mapUIntToULong(it)
}
if (l2.value != 10L) return "fail"
return "OK"
}