Handle reversed() in ForLoopsLowering.
We get the info for the underlying progression and invert it. For progressions whose last bound was open (e.g., `until` loop), the reversed version will have an open first bound and so the induction variable must be incremented first. Also unified the way of extracting HeaderInfo out of changed calls (e.g., `indices.reversed()`), and fixed declaration parents in ForLoopsLowering.
This commit is contained in:
committed by
max-kammerer
parent
3d1b6fb83c
commit
1b703448d3
+53
@@ -648,6 +648,39 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/arrays/forInReversed")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ForInReversed extends AbstractBlackBoxCodegenTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInForInReversed() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/arrays/forInReversed"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("reversedArrayOriginalUpdatedInLoopBody.kt")
|
||||
public void testReversedArrayOriginalUpdatedInLoopBody() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/forInReversed/reversedArrayOriginalUpdatedInLoopBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reversedArrayReversedArrayOriginalUpdatedInLoopBody.kt")
|
||||
public void testReversedArrayReversedArrayOriginalUpdatedInLoopBody() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/forInReversed/reversedArrayReversedArrayOriginalUpdatedInLoopBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reversedOriginalUpdatedInLoopBody.kt")
|
||||
public void testReversedOriginalUpdatedInLoopBody() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/forInReversed/reversedOriginalUpdatedInLoopBody.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reversedReversedOriginalUpdatedInLoopBody.kt")
|
||||
public void testReversedReversedOriginalUpdatedInLoopBody() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/arrays/forInReversed/reversedReversedOriginalUpdatedInLoopBody.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/arrays/multiDecl")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -18992,6 +19025,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedRangeLiteralWithNonConstBounds.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInReversedReversedArrayIndices.kt")
|
||||
public void testForInReversedReversedArrayIndices() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedReversedArrayIndices.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInReversedReversedDownTo.kt")
|
||||
public void testForInReversedReversedDownTo() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedReversedDownTo.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ForInReversedReversedRange.kt")
|
||||
public void testForInReversedReversedRange() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/ForInReversedReversedRange.kt");
|
||||
@@ -19002,6 +19045,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedReversedReversedRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInReversedReversedUntil.kt")
|
||||
public void testForInReversedReversedUntil() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedReversedUntil.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInReversedReversedUntilWithNonConstBounds.kt")
|
||||
public void testForInReversedReversedUntilWithNonConstBounds() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedReversedUntilWithNonConstBounds.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInReversedUntil.kt")
|
||||
public void testForInReversedUntil() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/ranges/forInReversed/forInReversedUntil.kt");
|
||||
|
||||
Reference in New Issue
Block a user