Support passing inline class values with spread operator
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(val value: Int)
|
||||
|
||||
fun <T> last(vararg e: T): T = e[e.size - 1]
|
||||
fun <T> first(vararg e: T): T = e[0]
|
||||
|
||||
fun box(): String {
|
||||
val u0 = UInt(0)
|
||||
val us = arrayOf(UInt(1), UInt(2), UInt(3))
|
||||
|
||||
if (last(u0, *us).value != 3) return "fail"
|
||||
if (first(*us, u0).value != 1) return "fail"
|
||||
if (first(u0, *us).value != 0) return "fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
compiler/testData/codegen/bytecodeText/inlineClasses/passInlineClassesWithSpreadOperatorToVarargs.kt
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(val u: Int)
|
||||
|
||||
fun <T> takeVarargs(vararg e: T) {}
|
||||
|
||||
fun test(u1: UInt, u2: UInt, us: Array<UInt>) {
|
||||
takeVarargs(*us) // copy + checkcast
|
||||
takeVarargs(u1, u2, *us) // 2 box + ...
|
||||
}
|
||||
|
||||
// 2 INVOKESTATIC UInt\$Erased.box
|
||||
// 0 INVOKEVIRTUAL UInt.unbox
|
||||
|
||||
// 2 CHECKCAST \[LUInt
|
||||
|
||||
// 0 CHECKCAST \[Ljava/lang/Integer
|
||||
|
||||
// 0 intValue
|
||||
// 0 valueOf
|
||||
Reference in New Issue
Block a user