Add test and check that iterator over UInt folds to a simple for-loop

This commit is contained in:
Mikhail Zarechenskiy
2018-02-07 14:09:31 +03:00
parent 059f1e9eed
commit b361d0e9c0
7 changed files with 185 additions and 0 deletions

View 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