mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Add test and check that iterator over UInt folds to a simple for-loop
This commit is contained in:
39
compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt
vendored
Normal file
39
compiler/testData/codegen/bytecodeText/inlineClasses/uIntArrayIteratorWithoutBoxing.kt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
|
||||
inline class UInt(private val value: Int)
|
||||
|
||||
inline class UIntArray(private val intArray: IntArray) {
|
||||
operator fun iterator(): UIntIterator = UIntIterator(intArray.iterator()) // create iterator
|
||||
}
|
||||
|
||||
inline class UIntIterator(private val intIterator: IntIterator) : Iterator<UInt> {
|
||||
override fun next(): UInt {
|
||||
return UInt(intIterator.next())
|
||||
}
|
||||
|
||||
override fun hasNext(): Boolean {
|
||||
return intIterator.hasNext()
|
||||
}
|
||||
}
|
||||
|
||||
fun uIntArrayOf(vararg u: Int): UIntArray = UIntArray(u)
|
||||
|
||||
fun test() {
|
||||
val a = uIntArrayOf(1, 2, 3, 4)
|
||||
for (element in a) {
|
||||
takeUInt(element)
|
||||
}
|
||||
}
|
||||
|
||||
fun takeUInt(u: UInt) {}
|
||||
|
||||
// 0 INVOKESTATIC UInt\$Erased.box
|
||||
// 0 INVOKEVIRTUAL UInt.unbox
|
||||
|
||||
// 0 INVOKEVIRTUAL UIntIterator.iterator
|
||||
// 1 INVOKESTATIC kotlin/jvm/internal/ArrayIteratorsKt.iterator
|
||||
|
||||
// 0 intValue
|
||||
|
||||
// inside wrong bridge
|
||||
// 1 valueOf
|
||||
Reference in New Issue
Block a user