Handle withIndex() on Iterables (including progressions) and Sequences

in ForLoopsLowering.
This commit is contained in:
Mark Punzalan
2019-11-05 11:15:33 -08:00
committed by max-kammerer
parent a54d9482dd
commit 7adffe0007
49 changed files with 1357 additions and 42 deletions
@@ -118,7 +118,7 @@ private class RangeLoopTransformer(
) : IrElementTransformerVoidWithContext() {
private val symbols = context.ir.symbols
private val headerInfoBuilder = HeaderInfoBuilder(context, this::getScopeOwnerSymbol)
private val headerInfoBuilder = DefaultHeaderInfoBuilder(context, this::getScopeOwnerSymbol)
private val headerProcessor = HeaderProcessor(context, headerInfoBuilder, this::getScopeOwnerSymbol)
fun getScopeOwnerSymbol() = currentScope!!.scope.scopeOwnerSymbol
@@ -212,6 +212,13 @@ internal class WithIndexHeaderInfo(val nestedInfo: HeaderInfo) : HeaderInfo() {
override fun asReversed(): HeaderInfo? = null
}
/**
* Information about a for-loop over an Iterable or Sequence.
*/
internal class IterableHeaderInfo(val iteratorVariable: IrVariable) : HeaderInfo() {
override fun asReversed(): HeaderInfo? = null
}
/** Matches an iterable expression and builds a [HeaderInfo] from the expression. */
internal interface HeaderInfoHandler<E : IrExpression, D> {
/** Returns true if the handler can build a [HeaderInfo] from the iterable expression. */
@@ -249,7 +256,7 @@ internal interface HeaderInfoFromCallHandler<D> : HeaderInfoHandler<IrCall, D> {
internal typealias ProgressionHandler = HeaderInfoFromCallHandler<ProgressionType>
internal class HeaderInfoBuilder(context: CommonBackendContext, private val scopeOwnerSymbol: () -> IrSymbol) :
internal abstract class HeaderInfoBuilder(context: CommonBackendContext, private val scopeOwnerSymbol: () -> IrSymbol) :
IrElementVisitor<HeaderInfo?, IrCall?> {
private val symbols = context.ir.symbols
@@ -272,19 +279,8 @@ internal class HeaderInfoBuilder(context: CommonBackendContext, private val scop
StepHandler(context, this)
)
private val callHandlers = listOf(
ReversedHandler(context, this),
WithIndexHandler(context, this)
)
// NOTE: StringIterationHandler MUST come before CharSequenceIterationHandler.
// String is subtype of CharSequence and therefore its handler is more specialized.
private val expressionHandlers = listOf(
ArrayIterationHandler(context),
DefaultProgressionHandler(context),
StringIterationHandler(context),
CharSequenceIterationHandler(context)
)
protected abstract val callHandlers: List<HeaderInfoFromCallHandler<Nothing?>>
protected abstract val expressionHandlers: List<ExpressionHandler>
override fun visitElement(element: IrElement, data: IrCall?): HeaderInfo? = null
@@ -309,4 +305,45 @@ internal class HeaderInfoBuilder(context: CommonBackendContext, private val scop
return expressionHandlers.firstNotNullResult { it.handle(iterable, iteratorCall, null, scopeOwnerSymbol()) }
?: super.visitExpression(iterable, iteratorCall)
}
}
internal class DefaultHeaderInfoBuilder(context: CommonBackendContext, scopeOwnerSymbol: () -> IrSymbol) :
HeaderInfoBuilder(context, scopeOwnerSymbol) {
override val callHandlers = listOf(
ReversedHandler(context, this),
WithIndexHandler(context, NestedHeaderInfoBuilderForWithIndex(context, scopeOwnerSymbol))
)
// NOTE: StringIterationHandler MUST come before CharSequenceIterationHandler.
// String is subtype of CharSequence and therefore its handler is more specialized.
override val expressionHandlers = listOf(
ArrayIterationHandler(context),
DefaultProgressionHandler(context),
StringIterationHandler(context),
CharSequenceIterationHandler(context)
)
}
// WithIndexHandler attempts to retrieve the HeaderInfo from the underlying index, using NestedHeaderInfoBuilderForWithIndex instead of
// DefaultHeaderInfoBuilder. The differences between the two are that NestedHeaderInfoBuilderForWithIndex:
//
// - Has NO WithIndexHandler. We do not attempt to optimize `*.withIndex().withIndex()`.
// - Has DefaultIterableHandler. This allows us to optimize `Iterable<*>.withIndex()` and `Sequence<*>.withIndex()`.
internal class NestedHeaderInfoBuilderForWithIndex(context: CommonBackendContext, scopeOwnerSymbol: () -> IrSymbol) :
HeaderInfoBuilder(context, scopeOwnerSymbol) {
// NOTE: No WithIndexHandler; we cannot lower `iterable.withIndex().withIndex()`.
override val callHandlers = listOf(
ReversedHandler(context, this)
)
// NOTE: StringIterationHandler MUST come before CharSequenceIterationHandler.
// String is subtype of CharSequence and therefore its handler is more specialized.
// DefaultIterableHandler must come last as it is handles iterables not handled by more specialized handlers.
override val expressionHandlers = listOf(
ArrayIterationHandler(context),
DefaultProgressionHandler(context),
StringIterationHandler(context),
CharSequenceIterationHandler(context),
DefaultIterableHandler(context)
)
}
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrDoWhileLoopImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrWhileLoopImpl
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.util.coerceToUnitIfNeeded
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
import org.jetbrains.kotlin.ir.util.functions
import org.jetbrains.kotlin.util.OperatorNameConventions
@@ -348,7 +349,7 @@ internal class IndexedGetLoopHeader(
}
internal class WithIndexLoopHeader(
private val headerInfo: WithIndexHeaderInfo,
headerInfo: WithIndexHeaderInfo,
builder: DeclarationIrBuilder
) : ForLoopHeader {
@@ -361,8 +362,9 @@ internal class WithIndexLoopHeader(
// To build the optimized/lowered `for` loop over a `withIndex()` call, we first need the header for the underlying iterable so
// so that we know how to build the loop for that iterable. More info in comments in initializeIteration().
nestedLoopHeader = when (val nestedInfo = headerInfo.nestedInfo) {
is IndexedGetHeaderInfo -> IndexedGetLoopHeader(nestedInfo, builder)
is ProgressionHeaderInfo -> ProgressionLoopHeader(nestedInfo, builder)
is IndexedGetHeaderInfo -> IndexedGetLoopHeader(nestedInfo, this@with)
is ProgressionHeaderInfo -> ProgressionLoopHeader(nestedInfo, this@with)
is IterableHeaderInfo -> IterableLoopHeader(nestedInfo)
is WithIndexHeaderInfo -> throw IllegalStateException("Nested WithIndexHeaderInfo not allowed for WithIndexLoopHeader")
}
@@ -424,9 +426,9 @@ internal class WithIndexLoopHeader(
// val step = 2
// if (inductionVar <= last) {
// do {
// val v = inductionVar
// inductionVar += step
// // Loop body
// val v = inductionVar
// inductionVar += step
// // Loop body
// } while (inductionVar <= last)
// }
//
@@ -438,14 +440,30 @@ internal class WithIndexLoopHeader(
// var index = 0 // ADDED
// if (inductionVar <= last) {
// do {
// val i = index // ADDED
// val v = inductionVar
// inductionVar += step
// // Loop body
// checkIndexOverflow(index++) // ADDED
// val i = index // ADDED
// val v = inductionVar
// inductionVar += step
// // Loop body
// checkIndexOverflow(index++) // ADDED
// } while (inductionVar <= last)
// }
//
// As another example, in a for-loop over a call to `Iterable<*>.withIndex()` or `Sequence<*>.withIndex()`, e.g.:
//
// for ((i, v) in listOf(2, 3, 5, 7, 11).withIndex()) { /* Loop body */ }
//
// For-loops over an Iterable are normally not optimized, but when getting the underlying iterable for `withIndex()` (and ONLY
// in this case), we use DefaultIterableHandler to match it and IterableLoopHeader to build the underlying loop. The optimized
// loop with `withIndex()` looks something like this:
//
// val iterator = listOf(2, 3, 5, 7, 11).iterator()
// var index = 0
// while (it.hasNext())
// val i = index
// val v = it.next()
// checkIndexOverflow(index++)
// }
//
// We "wire" the 1st destructured component to index, and the 2nd to the loop variable value from the underlying iterable.
loopVariableComponents[1]?.initializer = irGet(indexVariable)
listOfNotNull(loopVariableComponents[1]) + nestedLoopHeader.initializeIteration(
@@ -482,6 +500,53 @@ internal class WithIndexLoopHeader(
}
}
internal class IterableLoopHeader(
private val headerInfo: IterableHeaderInfo
) : ForLoopHeader {
override val loopInitStatements = listOf(headerInfo.iteratorVariable)
override val consumesLoopVariableComponents = false
override fun initializeIteration(
loopVariable: IrVariable?,
loopVariableComponents: Map<Int, IrVariable>,
symbols: Symbols<CommonBackendContext>,
builder: DeclarationIrBuilder
) =
with(builder) {
// loopVariable = iteratorVar.next()
val iteratorClass = headerInfo.iteratorVariable.type.getClass()!!
val next =
irCall(iteratorClass.functions.first { it.name == OperatorNameConventions.NEXT && it.valueParameters.isEmpty() }).apply {
dispatchReceiver = irGet(headerInfo.iteratorVariable)
}
loopVariable?.initializer = next
// Even if there is no loop variable, we always want to call `next()` for iterables and sequences.
listOf(loopVariable ?: next.coerceToUnitIfNeeded(next.type, context.irBuiltIns))
}
override fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?): LoopReplacement = with(builder) {
// Loop is lowered into something like:
//
// var iteratorVar = someIterable.iterator()
// while (iteratorVar.hasNext()) {
// val loopVar = iteratorVar.next()
// // Loop body
// }
val iteratorClass = headerInfo.iteratorVariable.type.getClass()!!
val hasNext =
irCall(iteratorClass.functions.first { it.name == OperatorNameConventions.HAS_NEXT && it.valueParameters.isEmpty() }).apply {
dispatchReceiver = irGet(headerInfo.iteratorVariable)
}
val newLoop = IrWhileLoopImpl(oldLoop.startOffset, oldLoop.endOffset, oldLoop.type, oldLoop.origin).apply {
label = oldLoop.label
condition = hasNext
body = newBody
}
LoopReplacement(newLoop, newLoop)
}
}
/**
* Given the for-loop iterator variable, extract information about the iterable subject
* and create a [ForLoopHeader] from it.
@@ -529,6 +594,7 @@ internal class HeaderProcessor(
is IndexedGetHeaderInfo -> IndexedGetLoopHeader(headerInfo, builder)
is ProgressionHeaderInfo -> ProgressionLoopHeader(headerInfo, builder)
is WithIndexHeaderInfo -> WithIndexLoopHeader(headerInfo, builder)
is IterableHeaderInfo -> IterableLoopHeader(headerInfo)
}
}
}
@@ -697,14 +697,14 @@ internal class StringIterationHandler(context: CommonBackendContext) : CharSeque
}
/** Builds a [HeaderInfo] for calls to `withIndex()`. */
internal class WithIndexHandler(context: CommonBackendContext, private val visitor: HeaderInfoBuilder) :
internal class WithIndexHandler(context: CommonBackendContext, private val visitor: NestedHeaderInfoBuilderForWithIndex) :
HeaderInfoFromCallHandler<Nothing?> {
// Use Quantifier.ANY so we can handle all `withIndex()` calls in the same manner.
override val matcher = createIrCallMatcher(Quantifier.ANY) {
callee {
fqName { it == FqName("kotlin.collections.withIndex") }
extensionReceiver { it != null && it.type.run { isArray() || isPrimitiveArray() } }
extensionReceiver { it != null && it.type.run { isArray() || isPrimitiveArray() || isIterable() } }
parameterCount { it == 0 }
}
callee {
@@ -712,8 +712,11 @@ internal class WithIndexHandler(context: CommonBackendContext, private val visit
extensionReceiver { it != null && it.type.isSubtypeOfClass(context.ir.symbols.charSequence) }
parameterCount { it == 0 }
}
// TODO: Handle Iterable.withIndex(), Sequence.withIndex()
callee {
fqName { it == FqName("kotlin.sequences.withIndex") }
extensionReceiver { it != null && it.type.run { isSequence() } }
parameterCount { it == 0 }
}
}
override fun build(expression: IrCall, data: Nothing?, scopeOwner: IrSymbol): HeaderInfo? {
@@ -721,8 +724,30 @@ internal class WithIndexHandler(context: CommonBackendContext, private val visit
val nestedInfo = expression.extensionReceiver!!.accept(visitor, null) ?: return null
// We cannot lower `iterable.withIndex().withIndex()`.
if (nestedInfo is WithIndexHeaderInfo) return null
// NestedHeaderInfoBuilderForWithIndex should not be yielding a WithIndexHeaderInfo, hence the assert.
assert(nestedInfo !is WithIndexHeaderInfo)
return WithIndexHeaderInfo(nestedInfo)
}
}
/** Builds a [HeaderInfo] for iterables not handled by more specialized handlers. */
internal class DefaultIterableHandler(private val context: CommonBackendContext) : ExpressionHandler {
override fun matchIterable(expression: IrExpression) = true
override fun build(expression: IrExpression, scopeOwner: IrSymbol): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
val iterableClass = expression.type.getClass()!!
val iterator =
irCall(iterableClass.functions.single {
it.name == OperatorNameConventions.ITERATOR &&
it.valueParameters.isEmpty()
}).apply {
dispatchReceiver = expression
}
IterableHeaderInfo(
scope.createTemporaryVariable(iterator, nameHint = "iterator")
)
}
}
@@ -73,6 +73,8 @@ fun IrType.isNumber(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.numb
fun IrType.isComparable(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.comparable.toUnsafe())
fun IrType.isCharSequence(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.charSequence)
fun IrType.isIterable(): Boolean = isNotNullClassType(KotlinBuiltIns.FQ_NAMES.iterable.toUnsafe())
fun IrType.isSequence(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.sequences.Sequence"))
fun IrType.isBooleanArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.BooleanArray"))
fun IrType.isCharArray(): Boolean = isNotNullClassType(FqNameUnsafe("kotlin.CharArray"))
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (7 downTo 4).withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(7, 6, 5, 4), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in listOf(4, 5, 6, 7).indices.withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(0, 1, 2, 3), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (4..7).withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(4, 5, 6, 7), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in ((4..11).reversed() step 2).withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(11, 9, 7, 5), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (4..7).reversed().withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(7, 6, 5, 4), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (4..11 step 2).reversed().withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(10, 8, 6, 4), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (4..11 step 2).withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(4, 6, 8, 10), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (4 until 8).withIndex()) {
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(4, 5, 6, 7), valueList)
return "OK"
}
@@ -0,0 +1,15 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
var count = 0
for ((_, _) in (4..7).withIndex()) {
count++
}
assertEquals(4, count)
return "OK"
}
@@ -0,0 +1,19 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for (iv in (4..7).withIndex()) {
val (i, v) = iv
indexList += i
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(4, 5, 6, 7), valueList)
return "OK"
}
@@ -0,0 +1,18 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((i, v) in (4..7).withIndex().reversed()) {
indexList += i
valueList += v
}
assertEquals(listOf(3, 2, 1, 0), indexList)
assertEquals(listOf(7, 6, 5, 4), valueList)
return "OK"
}
@@ -0,0 +1,23 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val indexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
val valueAndIndexList = mutableListOf<Int>()
for ((i, v) in (4..7).withIndex()) {
val (v2, i2) = Pair(v, i)
indexList += i
valueList += v
valueAndIndexList += v2
valueAndIndexList += i2
}
assertEquals(listOf(0, 1, 2, 3), indexList)
assertEquals(listOf(4, 5, 6, 7), valueList)
assertEquals(listOf(4, 0, 5, 1, 6, 2, 7, 3), valueAndIndexList)
return "OK"
}
@@ -0,0 +1,22 @@
// IGNORE_BACKEND_FIR: JVM_IR
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
val outerIndexList = mutableListOf<Int>()
val innerIndexList = mutableListOf<Int>()
val valueList = mutableListOf<Int>()
for ((outer, iv) in (4..7).withIndex().withIndex()) {
outerIndexList += outer
val (inner, v) = iv
innerIndexList += inner
valueList += v
}
assertEquals(listOf(0, 1, 2, 3), outerIndexList)
assertEquals(listOf(0, 1, 2, 3), innerIndexList)
assertEquals(listOf(4, 5, 6, 7), valueList)
return "OK"
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf<Any>()
fun box(): String {
@@ -15,3 +14,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d")
fun box(): String {
@@ -18,3 +17,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d")
fun box(): String {
@@ -18,3 +17,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d")
fun box(): String {
@@ -18,3 +17,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d")
fun useAny(x: Any) {}
@@ -21,3 +20,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -0,0 +1,28 @@
fun box(): String {
for ((i, v) in (7 downTo 4).withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
@@ -0,0 +1,29 @@
fun box(): String {
for ((i, v) in listOf(4, 5, 6, 7).indices.withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
// 0 getIndices
@@ -0,0 +1,28 @@
fun box(): String {
for ((i, v) in (4..7).withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
@@ -0,0 +1,30 @@
fun box(): String {
for ((i, v) in ((4..11).reversed() step 2).withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
// 0 reversed
// 0 step
@@ -0,0 +1,29 @@
fun box(): String {
for ((i, v) in (4..7).reversed().withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
// 0 reversed
@@ -0,0 +1,30 @@
fun box(): String {
for ((i, v) in (4..11 step 2).reversed().withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
// 0 reversed
// 0 step
@@ -0,0 +1,29 @@
fun box(): String {
for ((i, v) in (4..11 step 2).withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
// 0 step
@@ -0,0 +1,28 @@
fun box(): String {
for ((i, v) in (4 until 8).withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
@@ -0,0 +1,28 @@
fun box(): String {
for ((_, _) in (4..7).withIndex()) {
}
return "OK"
}
// 0 withIndex
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
// JVM_TEMPLATES
// 1 iterator
// 1 hasNext
// 1 next
// JVM_IR_TEMPLATES
// 0 iterator
// 0 hasNext
// 0 next
// 0 getStart
// 0 getEnd
// 0 getFirst
// 0 getLast
// 0 getStep
@@ -0,0 +1,15 @@
fun box(): String {
for (iv in (4..7).withIndex()) {
}
return "OK"
}
// We do not optimize `withIndex()` if the loop variable is not destructured
// 1 withIndex
// 1 iterator
// 1 hasNext
// 1 next
// 0 component1
// 0 component2
@@ -0,0 +1,16 @@
fun box(): String {
for ((i, v) in (4..7).withIndex().reversed()) {
}
return "OK"
}
// We do not optimize `withIndex().reversed()`
// 1 withIndex
// 1 iterator
// 1 hasNext
// 1 next
// 1 component1
// 1 component2
// 1 reversed
@@ -0,0 +1,18 @@
fun box(): String {
for ((outer, iv) in (4..7).withIndex().withIndex()) {
}
return "OK"
}
// We optimize the outer `withIndex()` and treat the inner one as an Iterable
// 1 withIndex
// 1 iterator
// 1 hasNext
// 1 next
// 0 component1
// 0 component2
// The ICONST_0 is for initializing the index in the lowered for-loop.
// 1 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf<Any>().asSequence()
fun box(): String {
@@ -15,3 +14,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d").asSequence()
fun box(): String {
@@ -18,3 +17,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d").asSequence()
fun box(): String {
@@ -18,3 +17,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d").asSequence()
fun box(): String {
@@ -18,3 +17,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
// FULL_JDK
val xsl = arrayListOf("a", "b", "c", "d")
@@ -29,3 +28,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for cmeThrown. 3rd is for initializing the index in the lowered for-loop.
// 3 ICONST_0
@@ -1,4 +1,3 @@
// IGNORE_BACKEND: JVM_IR
val xs = listOf("a", "b", "c", "d").asSequence()
fun useAny(x: Any) {}
@@ -21,3 +20,6 @@ fun box(): String {
// 1 next
// 0 component1
// 0 component2
// The 1st ICONST_0 is for initializing the list. 2nd is for initializing the index in the lowered for-loop.
// 2 ICONST_0
@@ -20265,6 +20265,84 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithDestructuringInLoop.kt")
public void testForInWithIndexWithDestructuringInLoop() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithDestructuringInLoop.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -2007,6 +2007,79 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractBytecodeTextTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -20265,6 +20265,84 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractLightAnalysisModeTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithDestructuringInLoop.kt")
public void testForInWithIndexWithDestructuringInLoop() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithDestructuringInLoop.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -18800,6 +18800,84 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractFirBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: ");
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithDestructuringInLoop.kt")
public void testForInWithIndexWithDestructuringInLoop() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithDestructuringInLoop.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -18800,6 +18800,84 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractIrBlackBoxCodegenTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithDestructuringInLoop.kt")
public void testForInWithIndexWithDestructuringInLoop() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithDestructuringInLoop.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -1962,6 +1962,79 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractIrBytecodeTextTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -15950,6 +15950,84 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractIrJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithDestructuringInLoop.kt")
public void testForInWithIndexWithDestructuringInLoop() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithDestructuringInLoop.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -17125,6 +17125,84 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInProgressionWithIndex extends AbstractJsCodegenBoxTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
}
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
}
@TestMetadata("forInDownToWithIndex.kt")
public void testForInDownToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInDownToWithIndex.kt");
}
@TestMetadata("forInIndicesWithIndex.kt")
public void testForInIndicesWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInIndicesWithIndex.kt");
}
@TestMetadata("forInRangeToWithIndex.kt")
public void testForInRangeToWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInRangeToWithIndex.kt");
}
@TestMetadata("forInReversedStepWithIndex.kt")
public void testForInReversedStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedStepWithIndex.kt");
}
@TestMetadata("forInReversedWithIndex.kt")
public void testForInReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInReversedWithIndex.kt");
}
@TestMetadata("forInStepReversedWithIndex.kt")
public void testForInStepReversedWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepReversedWithIndex.kt");
}
@TestMetadata("forInStepWithIndex.kt")
public void testForInStepWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInStepWithIndex.kt");
}
@TestMetadata("forInUntilWithIndex.kt")
public void testForInUntilWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInUntilWithIndex.kt");
}
@TestMetadata("forInWithIndexNoIndexOrElementVar.kt")
public void testForInWithIndexNoIndexOrElementVar() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNoIndexOrElementVar.kt");
}
@TestMetadata("forInWithIndexNotDestructured.kt")
public void testForInWithIndexNotDestructured() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexNotDestructured.kt");
}
@TestMetadata("forInWithIndexReversed.kt")
public void testForInWithIndexReversed() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexReversed.kt");
}
@TestMetadata("forInWithIndexWithDestructuringInLoop.kt")
public void testForInWithIndexWithDestructuringInLoop() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithDestructuringInLoop.kt");
}
@TestMetadata("forInWithIndexWithIndex.kt")
public void testForInWithIndexWithIndex() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)