From 9fa9a8748b1cbe81290aa027e3d85e9dae6f602c Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 12 Dec 2017 16:26:14 +0300 Subject: [PATCH] Check that qualified const expressions are recognized properly in 'for' --- .../forLoop/forInRangeToQualifiedConst.kt | 15 +++++++++++++++ .../kotlin/codegen/BytecodeTextTestGenerated.java | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt new file mode 100644 index 00000000000..ddd991ffe97 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt @@ -0,0 +1,15 @@ +object Host { + const val M = 1 + const val N = 4 +} + +fun test(): Int { + var s = 0 + for (i in Host.M .. Host.N) { + s += i + } + return s +} + +// 0 IF_ICMPEQ +// 1 IF_ICMPGT \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 79fdd607134..ddf677db5c1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -1307,6 +1307,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { doTest(fileName); } + @TestMetadata("forInRangeToQualifiedConst.kt") + public void testForInRangeToQualifiedConst() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt"); + doTest(fileName); + } + @TestMetadata("forInRangeWithImplicitReceiver.kt") public void testForInRangeWithImplicitReceiver() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInRangeWithImplicitReceiver.kt");