Do not cache "last" value (i.e., size/length) in lowered for-loop

iteration over CharSequences.

CharSequences may be mutable (e.g., StringBuilder) and therefore its
contents and length can change within the loop.
This commit is contained in:
Mark Punzalan
2019-09-26 15:25:50 -07:00
committed by max-kammerer
parent 3da3e1cae9
commit c16b59191b
10 changed files with 226 additions and 92 deletions
@@ -18819,6 +18819,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/ranges/forByteProgressionWithIntIncrement.kt");
}
@TestMetadata("forInCharSequenceLengthDecreasedInLoopBody.kt")
public void testForInCharSequenceLengthDecreasedInLoopBody() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInCharSequenceLengthDecreasedInLoopBody.kt");
}
@TestMetadata("forInCharSequenceLengthIncreasedInLoopBody.kt")
public void testForInCharSequenceLengthIncreasedInLoopBody() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInCharSequenceLengthIncreasedInLoopBody.kt");
}
@TestMetadata("forInRangeLiteralWithMixedTypeBounds.kt")
public void testForInRangeLiteralWithMixedTypeBounds() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInRangeLiteralWithMixedTypeBounds.kt");