Files
kotlin/compiler/testData/codegen/box/inlineClasses/inlineClassesInInlineLambdaParameters.kt
Dmitry Petrov 6e2d05cd94 Fix argument original type order in InlineCodegen
Arguments are put on stack in the direct order, and then stored into
local variables for inlining in the reversed order:

    <arg0>
    <arg1>
    <arg2>
    store <param2>
    store <param1>
    store <param0>

Original value parameter types were taken in direct order, though.
2018-08-24 14:52:29 +03:00

25 lines
794 B
Kotlin
Vendored

// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND: JVM_IR
inline class Z(val int: Int)
inline class L(val long: Long)
inline fun <T, R> s0(x: T, fn: (Int, T) -> R) = fn(0, x)
inline fun <T, R> weirdMix(x: T, fn: (Int, T, Long, T) -> R) = fn(0, x, 0L, x)
fun testS0Z(x: Z) = s0(x) { _, xx -> Z(xx.int + 1) }
fun testS0L(x: L) = s0(x) { _, xx -> L(xx.long + 1L) }
fun testWeirdMixZ(x: Z) = weirdMix(x) { _, xx, _, _ -> Z(xx.int + 1) }
fun testWeirdMixL(x: L) = weirdMix(x) { _, xx, _, _ -> L(xx.long + 1L) }
fun box(): String {
if (testS0Z(Z(42)).int != 43) throw AssertionError()
if (testS0L(L(42L)).long != 43L) throw AssertionError()
if (testWeirdMixZ(Z(42)).int != 43) throw AssertionError()
if (testWeirdMixL(L(42L)).long != 43L) throw AssertionError()
return "OK"
}