KT-42909 fix missing loop variable in 'withIndex' ranges
This commit is contained in:
Generated
+5
@@ -22755,6 +22755,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
+3
-6
@@ -297,7 +297,7 @@ internal class ProgressionLoopHeader(
|
|||||||
|
|
||||||
// loopVariable = inductionVariable
|
// loopVariable = inductionVariable
|
||||||
// inductionVariable = inductionVariable + step
|
// inductionVariable = inductionVariable + step
|
||||||
listOfNotNull(loopVariable, incrementInductionVariable(this))
|
listOfNotNull(this@ProgressionLoopHeader.loopVariable, incrementInductionVariable(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?) =
|
override fun buildLoop(builder: DeclarationIrBuilder, oldLoop: IrLoop, newBody: IrExpression?) =
|
||||||
@@ -552,11 +552,8 @@ internal class WithIndexLoopHeader(
|
|||||||
//
|
//
|
||||||
// We "wire" the 1st destructured component to index, and the 2nd to the loop variable value from the underlying iterable.
|
// 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)
|
loopVariableComponents[1]?.initializer = irGet(indexVariable)
|
||||||
listOfNotNull(loopVariableComponents[1], incrementIndexStatement) + nestedLoopHeader.initializeIteration(
|
listOfNotNull(loopVariableComponents[1], incrementIndexStatement) +
|
||||||
loopVariableComponents[2],
|
nestedLoopHeader.initializeIteration(loopVariableComponents[2], linkedMapOf(), builder)
|
||||||
linkedMapOf(),
|
|
||||||
builder
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the nested loop header to build the loop. More info in comments in initializeIteration().
|
// Use the nested loop header to build the loop. More info in comments in initializeIteration().
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// KJS_WITH_FULL_RUNTIME
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var r = test()
|
||||||
|
if (r != "01") throw AssertionError(r.toString())
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun test(): String {
|
||||||
|
var r = ""
|
||||||
|
for ((i, _) in (1..'c' - 'a').withIndex()) {
|
||||||
|
r += i.toString()
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
+5
@@ -24526,6 +24526,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
+5
@@ -24526,6 +24526,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
+5
@@ -22755,6 +22755,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
Generated
+5
@@ -18946,6 +18946,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
Generated
+5
@@ -18946,6 +18946,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
+5
@@ -19051,6 +19051,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
public void testForInWithIndexWithIndex() throws Exception {
|
public void testForInWithIndexWithIndex() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/forInWithIndexWithIndex.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
Generated
+5
@@ -11807,6 +11807,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
|
public void testAllFilesPresentInForInProgressionWithIndex() throws Exception {
|
||||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInProgressionWithIndex"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt42909.kt")
|
||||||
|
public void testKt42909() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/ranges/forInProgressionWithIndex/kt42909.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
@TestMetadata("compiler/testData/codegen/box/ranges/forInReversed")
|
||||||
|
|||||||
Reference in New Issue
Block a user