Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/passInlineClassAsVararg.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

26 lines
559 B
Kotlin
Vendored

// WITH_STDLIB
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@kotlin.jvm.JvmInline
value class UInt(val value: Int)
fun <T> takeVarargs(vararg e: T): T {
return e[e.size - 1]
}
fun test(u1: UInt, u2: UInt, u3: UInt?): Int {
val a = takeVarargs(u1, u2)
val b = takeVarargs(u3) ?: UInt(-1)
val c = takeVarargs(u1, u3) ?: UInt(-1)
return a.value + b.value + c.value
}
fun box(): String {
val u1 = UInt(0)
val u2 = UInt(1)
val u3 = UInt(2)
if (test(u1, u2, u3) != 1 + 2 + 2) return "fail"
return "OK"
}