Files
kotlin-fork/compiler/testData/ir/interpreter/rangeTo.kt
T
Ivan Kylchik 4f15bd4817 Introduce a workaround in interpreter tests to make them pass
There is a problem with ranges and iterators. To work properly
they must be resolved firstly, before operator rangeTo.
2021-08-06 13:33:33 +03:00

16 lines
655 B
Kotlin
Vendored

// this hack is used to ensure that iterator will be resolved first
@CompileTimeCalculation internal class IntProgressionIterator(first: Int, last: Int, val step: Int) : IntIterator()
@CompileTimeCalculation public class IntRange(start: Int, endInclusive: Int) : IntProgression(start, endInclusive, 1), ClosedRange<Int>
const val range = (1..10).<!EVALUATED: `1`!>first<!>
@CompileTimeCalculation
fun getIterator(first: Int, last: Int): Int {
val iterator = (first..last).iterator()
iterator.nextInt()
iterator.nextInt()
iterator.nextInt()
return iterator.nextInt()
}
const val testIterator = <!EVALUATED: `4`!>getIterator(1, 10)<!>