mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 15:53:55 +00:00
Support inline classes working with collection elements (get/set)
This commit is contained in:
23
compiler/testData/codegen/bytecodeText/inlineClasses/uIntArraySwapBoxing.kt
vendored
Normal file
23
compiler/testData/codegen/bytecodeText/inlineClasses/uIntArraySwapBoxing.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(private val value: Int) {
|
||||
fun asInt() = value
|
||||
}
|
||||
|
||||
inline class UIntArray(private val intArray: IntArray) {
|
||||
operator fun get(index: Int): UInt = UInt(intArray[index])
|
||||
|
||||
operator fun set(index: Int, value: UInt) {
|
||||
intArray[index] = value.asInt()
|
||||
}
|
||||
}
|
||||
|
||||
fun UIntArray.swap(i: Int, j: Int) {
|
||||
this[j] = this[i].also { this[i] = this[j] }
|
||||
}
|
||||
|
||||
// 2 INVOKEVIRTUAL UInt.unbox
|
||||
// 1 INVOKESTATIC UInt\$Erased.box
|
||||
|
||||
// 0 intValue
|
||||
// 0 valueOf
|
||||
Reference in New Issue
Block a user