diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java index 3135131c14a79..7662a4f0f1433 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/RangeCodegenUtil.java @@ -134,6 +134,17 @@ public static boolean isPrimitiveNumberDownTo(@NotNull CallableDescriptor descri return true; } + public static boolean isPrimitiveNumberUntil(@NotNull CallableDescriptor descriptor) { + if (!isTopLevelInPackage(descriptor, "until", "kotlin.ranges")) return false; + + ReceiverParameterDescriptor extensionReceiver = descriptor.getExtensionReceiverParameter(); + if (extensionReceiver == null) return false; + ClassifierDescriptor extensionReceiverClassifier = extensionReceiver.getType().getConstructor().getDeclarationDescriptor(); + if (!isPrimitiveNumberClassDescriptor(extensionReceiverClassifier)) return false; + + return true; + } + public static boolean isArrayOrPrimitiveArrayIndices(@NotNull CallableDescriptor descriptor) { if (!isTopLevelInPackage(descriptor, "indices", "kotlin.collections")) return false; diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForInRangeLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForInRangeLoopGenerator.kt index ff142441bb88a..57bc17aef0cb9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForInRangeLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForInRangeLoopGenerator.kt @@ -66,9 +66,13 @@ abstract class AbstractForInRangeLoopGenerator : AbstractForInProgressionOrRange override fun assignToLoopParameter() {} - override fun increment(loopExit: Label) { + override fun checkPostConditionAndIncrement(loopExit: Label) { checkPostCondition(loopExit) + incrementLoopVariable() + } + + protected fun incrementLoopVariable() { if (loopParameterType === Type.INT_TYPE) { v.iinc(loopParameterVar, step) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForLoopGenerator.kt index 6e917186e5a31..6a3391c2bc189 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/AbstractForLoopGenerator.kt @@ -116,7 +116,7 @@ abstract class AbstractForLoopGenerator( protected abstract fun assignToLoopParameter() - protected abstract fun increment(loopExit: Label) + protected abstract fun checkPostConditionAndIncrement(loopExit: Label) fun body() { codegen.generateLoopBody(forExpression.body) @@ -135,7 +135,7 @@ abstract class AbstractForLoopGenerator( fun afterBody(loopExit: Label) { codegen.markStartLineNumber(forExpression) - increment(loopExit) + checkPostConditionAndIncrement(loopExit) v.mark(bodyEnd) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInArrayLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInArrayLoopGenerator.kt index 5badbd2fdf079..9beb83d8941d3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInArrayLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInArrayLoopGenerator.kt @@ -74,7 +74,7 @@ class ForInArrayLoopGenerator(codegen: ExpressionCodegen, forExpression: KtForEx v.store(loopParameterVar, asmElementType) } - override fun increment(loopExit: Label) { + override fun checkPostConditionAndIncrement(loopExit: Label) { v.iinc(indexVar, 1) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInCharSequenceLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInCharSequenceLoopGenerator.kt index 91a7de1b1169a..15b015b440a58 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInCharSequenceLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInCharSequenceLoopGenerator.kt @@ -67,7 +67,7 @@ class ForInCharSequenceLoopGenerator(codegen: ExpressionCodegen, forExpression: v.store(loopParameterVar, asmElementType) } - override fun increment(loopExit: Label) { + override fun checkPostConditionAndIncrement(loopExit: Label) { v.iinc(indexVar, 1) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInProgressionExpressionLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInProgressionExpressionLoopGenerator.kt index 066de50ed967d..4fb43ad8948d9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInProgressionExpressionLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInProgressionExpressionLoopGenerator.kt @@ -92,7 +92,7 @@ class ForInProgressionExpressionLoopGenerator(codegen: ExpressionCodegen, forExp override fun assignToLoopParameter() {} - override fun increment(loopExit: Label) { + override fun checkPostConditionAndIncrement(loopExit: Label) { checkPostCondition(loopExit) val loopParameter = loopParameter() diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInUntilRangeLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInUntilRangeLoopGenerator.kt new file mode 100644 index 0000000000000..9fab90aa0e1d0 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForInUntilRangeLoopGenerator.kt @@ -0,0 +1,58 @@ +/* + * Copyright 2010-2017 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.codegen.forLoop + +import org.jetbrains.kotlin.codegen.ExpressionCodegen +import org.jetbrains.kotlin.codegen.StackValue +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtForExpression +import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue +import org.jetbrains.org.objectweb.asm.Label +import org.jetbrains.org.objectweb.asm.Type + +class ForInUntilRangeLoopGenerator( + codegen: ExpressionCodegen, + forExpression: KtForExpression, + loopRangeCall: ResolvedCall<*> +) : AbstractForInRangeLoopGenerator(codegen, forExpression) { + private val from: ReceiverValue = loopRangeCall.extensionReceiver!! + private val to: KtExpression = ExpressionCodegen.getSingleArgumentExpression(loopRangeCall)!! + + override fun storeRangeStartAndEnd() { + loopParameter().store(codegen.generateReceiverValue(from, false), v) + StackValue.local(endVar, asmElementType).store(codegen.gen(to), v) + } + + override fun checkEmptyLoop(loopExit: Label) {} + + override fun checkPreCondition(loopExit: Label) { + loopParameter().put(asmElementType, v) + v.load(endVar, asmElementType) + if (asmElementType.sort == Type.LONG) { + v.lcmp() + v.ifge(loopExit) + } + else { + v.ificmpge(loopExit) + } + } + + override fun checkPostConditionAndIncrement(loopExit: Label) { + incrementLoopVariable() + } +} diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForLoopGenerators.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForLoopGenerators.kt index cdbf8287cf119..d6bbac3fdc676 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForLoopGenerators.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/ForLoopGenerators.kt @@ -68,6 +68,8 @@ private fun ExpressionCodegen.createOptimizedForLoopGeneratorOrNull( ForInRangeLiteralLoopGenerator(this, forExpression, loopRangeCall) RangeCodegenUtil.isPrimitiveNumberDownTo(loopRangeCallee) -> ForInDownToProgressionLoopGenerator(this, forExpression, loopRangeCall) + RangeCodegenUtil.isPrimitiveNumberUntil(loopRangeCallee) -> + ForInUntilRangeLoopGenerator(this, forExpression, loopRangeCall) RangeCodegenUtil.isArrayOrPrimitiveArrayIndices(loopRangeCallee) -> ForInArrayIndicesRangeLoopGenerator(this, forExpression, loopRangeCall) RangeCodegenUtil.isCollectionIndices(loopRangeCallee) -> diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/IteratorForLoopGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/IteratorForLoopGenerator.kt index e7bb69b767930..cdf3aff4750d7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/IteratorForLoopGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/forLoop/IteratorForLoopGenerator.kt @@ -83,5 +83,5 @@ class IteratorForLoopGenerator(codegen: ExpressionCodegen, forExpression: KtForE StackValue.local(loopParameterVar, loopParameterType).store(value, v) } - override fun increment(loopExit: Label) {} + override fun checkPostConditionAndIncrement(loopExit: Label) {} } diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt new file mode 100644 index 0000000000000..71fcc47486b21 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt @@ -0,0 +1,28 @@ +// IGNORE_BACKEND: JS +// see KT-17700 + +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + testChar() + testNullableChar() + return "OK" +} + +private fun testChar() { + var sum = "" + for (ch in '1' until '5') { + sum = sum + ch + } + assertEquals("1234", sum) +} + +private fun testNullableChar() { + var sum = "" + for (ch: Char? in '1' until '5') { + sum = sum + (ch ?: break) + } + assertEquals("1234", sum) +} diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt new file mode 100644 index 0000000000000..5b7357ba109d1 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + for (ch in (-10).toChar() until '\u0000') { + throw AssertionError("This loop shoud not be executed") + } + return "OK" +} diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt new file mode 100644 index 0000000000000..45e865c4d722d --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt @@ -0,0 +1,25 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + testIntInIntUntilInt() + testNullableIntInIntUntilInt() + return "OK" +} + +private fun testIntInIntUntilInt() { + var sum = 0 + for (i in 1 until 5) { + sum = sum * 10 + i + } + assertEquals(1234, sum) +} + +private fun testNullableIntInIntUntilInt() { + var sum = 0 + for (i: Int? in 1 until 5) { + sum = sum * 10 + (i?.toInt() ?: break) + } + assertEquals(1234, sum) +} diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt new file mode 100644 index 0000000000000..549b8d6fa9ac6 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + for (i in 10 until 0) { + throw AssertionError("This loop should not be executed") + } + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt new file mode 100644 index 0000000000000..93e0853225bf5 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt @@ -0,0 +1,43 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun testLongInLongUntilLong() { + var sum = 0 + for (i in 1L until 5L) { + sum = sum * 10 + i.toInt() + } + assertEquals(1234, sum) +} + +fun testLongInLongUntilInt() { + var sum = 0 + for (i in 1L until 5.toInt()) { + sum = sum * 10 + i.toInt() + } + assertEquals(1234, sum) +} + +fun testLongInIntUntilLong() { + var sum = 0 + for (i in 1.toInt() until 5L) { + sum = sum * 10 + i.toInt() + } + assertEquals(1234, sum) +} + +fun testNullableLongInIntUntilLong() { + var sum = 0 + for (i: Long? in 1.toInt() until 5L) { + sum = sum * 10 + (i?.toInt() ?: break) + } + assertEquals(1234, sum) +} + +fun box(): String { + testLongInLongUntilLong() + testLongInIntUntilLong() + testLongInLongUntilInt() + testNullableLongInIntUntilLong() + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt new file mode 100644 index 0000000000000..bf012c8d0ff77 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + for (i in Int.MAX_VALUE until Int.MAX_VALUE) { + throw AssertionError("This loop shoud not be executed") + } + return "OK" +} diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt new file mode 100644 index 0000000000000..31ae7acede263 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + for (i in 0 until Int.MIN_VALUE) { + throw AssertionError("This loop shoud not be executed") + } + return "OK" +} diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt new file mode 100644 index 0000000000000..b44b7f9f44001 --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + for (i in 0 until Long.MIN_VALUE) { + throw AssertionError("This loop shoud not be executed") + } + return "OK" +} diff --git a/compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt b/compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt new file mode 100644 index 0000000000000..0cbaf4531ad4e --- /dev/null +++ b/compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt @@ -0,0 +1,21 @@ +// WITH_RUNTIME + +import kotlin.test.assertEquals + +fun box(): String { + testIntInIntUntilSmartcastInt() + return "OK" +} + +private fun testIntInIntUntilSmartcastInt() { + var sum = 0 + + val a: Any = 5 + if (a is Int) { + for (i: Int in 1 until a) { + sum = sum * 10 + i + } + } + + assertEquals(1234, sum) +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil.kt new file mode 100644 index 0000000000000..37a118177a51c --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil.kt @@ -0,0 +1,16 @@ +// WITH_RUNTIME + +fun test(): Int { + var sum = 0 + for (i in 1 until 6) { + sum = sum * 10 + i + } + return sum +} + +// 0 iterator +// 0 getStart +// 0 getEnd +// 0 getFirst +// 0 getLast +// 1 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/intRangeNoBoxing.kt b/compiler/testData/codegen/bytecodeText/intRangeNoBoxing.kt index 0e0811d4f85cc..766ede8b31721 100644 --- a/compiler/testData/codegen/bytecodeText/intRangeNoBoxing.kt +++ b/compiler/testData/codegen/bytecodeText/intRangeNoBoxing.kt @@ -1,6 +1,7 @@ fun Int.until(other: Int) = this..other - 1 fun foo() { - for (i in 1 until 2) { + val range = 1 until 2 + for (i in range) { } for (i in 1..2 step 4) {} diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 1e6ed20a8f8e0..9c2c373e213eb 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -13364,6 +13364,69 @@ public void testKt13241_Collection() throws Exception { } } + @TestMetadata("compiler/testData/codegen/box/ranges/forInUntil") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ForInUntil extends AbstractIrBlackBoxCodegenTest { + public void testAllFilesPresentInForInUntil() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("forInUntilChar.kt") + public void testForInUntilChar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilChar0.kt") + public void testForInUntilChar0() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilInt.kt") + public void testForInUntilInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLesserInt.kt") + public void testForInUntilLesserInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLong.kt") + public void testForInUntilLong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMaxint.kt") + public void testForInUntilMaxint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinint.kt") + public void testForInUntilMinint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinlong.kt") + public void testForInUntilMinlong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt"); + doTest(fileName); + } + + @TestMetadata("forIntInIntUntilSmartcastInt.kt") + public void testForIntInIntUntilSmartcastInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/ranges/literal") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 3b6425a7c0664..ab3570abaa42c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13364,6 +13364,69 @@ public void testKt13241_Collection() throws Exception { } } + @TestMetadata("compiler/testData/codegen/box/ranges/forInUntil") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ForInUntil extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInForInUntil() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("forInUntilChar.kt") + public void testForInUntilChar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilChar0.kt") + public void testForInUntilChar0() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilInt.kt") + public void testForInUntilInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLesserInt.kt") + public void testForInUntilLesserInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLong.kt") + public void testForInUntilLong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMaxint.kt") + public void testForInUntilMaxint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinint.kt") + public void testForInUntilMinint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinlong.kt") + public void testForInUntilMinlong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt"); + doTest(fileName); + } + + @TestMetadata("forIntInIntUntilSmartcastInt.kt") + public void testForIntInIntUntilSmartcastInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/ranges/literal") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 1c86a18c609cd..ae0cddf62321a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -1151,6 +1151,12 @@ public void testForInRangeWithImplicitReceiver() throws Exception { doTest(fileName); } + @TestMetadata("forInUntil.kt") + public void testForInUntil() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInUntil.kt"); + doTest(fileName); + } + @TestMetadata("forIntInDownTo.kt") public void testForIntInDownTo() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/forIntInDownTo.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 7d4b0db75e79f..d9d57baf0c2de 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13364,6 +13364,69 @@ public void testKt13241_Collection() throws Exception { } } + @TestMetadata("compiler/testData/codegen/box/ranges/forInUntil") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ForInUntil extends AbstractLightAnalysisModeTest { + public void testAllFilesPresentInForInUntil() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("forInUntilChar.kt") + public void testForInUntilChar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilChar0.kt") + public void testForInUntilChar0() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilInt.kt") + public void testForInUntilInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLesserInt.kt") + public void testForInUntilLesserInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLong.kt") + public void testForInUntilLong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMaxint.kt") + public void testForInUntilMaxint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinint.kt") + public void testForInUntilMinint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinlong.kt") + public void testForInUntilMinlong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt"); + doTest(fileName); + } + + @TestMetadata("forIntInIntUntilSmartcastInt.kt") + public void testForIntInIntUntilSmartcastInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/ranges/literal") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 6807fc97edb79..5ee5bf852a037 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -15184,6 +15184,75 @@ public void testKt13241_Collection() throws Exception { } } + @TestMetadata("compiler/testData/codegen/box/ranges/forInUntil") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ForInUntil extends AbstractJsCodegenBoxTest { + public void testAllFilesPresentInForInUntil() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/ranges/forInUntil"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("forInUntilChar.kt") + public void testForInUntilChar() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + + @TestMetadata("forInUntilChar0.kt") + public void testForInUntilChar0() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilChar0.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilInt.kt") + public void testForInUntilInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLesserInt.kt") + public void testForInUntilLesserInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLesserInt.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilLong.kt") + public void testForInUntilLong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilLong.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMaxint.kt") + public void testForInUntilMaxint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMaxint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinint.kt") + public void testForInUntilMinint() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinint.kt"); + doTest(fileName); + } + + @TestMetadata("forInUntilMinlong.kt") + public void testForInUntilMinlong() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forInUntilMinlong.kt"); + doTest(fileName); + } + + @TestMetadata("forIntInIntUntilSmartcastInt.kt") + public void testForIntInIntUntilSmartcastInt() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/forInUntil/forIntInIntUntilSmartcastInt.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/codegen/box/ranges/literal") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java index 76c4255046ceb..4e3aaea953d3b 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java @@ -59,4 +59,5 @@ public void testSimpleWithPrefixAndPostfix() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/outputPrefixPostfix/simpleWithPrefixAndPostfix.kt"); doTest(fileName); } + } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java index d9470ebf8c70c..dccfefd35fb3a 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java @@ -53,4 +53,5 @@ public void testMethodCallInMethod() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/sourcemap/methodCallInMethod.kt"); doTest(fileName); } + }