diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/range/InPrimitiveNumberUntilGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/range/InPrimitiveNumberUntilGenerator.kt index c64993983e4..0a1c89edcba 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/range/InPrimitiveNumberUntilGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/range/InPrimitiveNumberUntilGenerator.kt @@ -28,7 +28,7 @@ class InPrimitiveNumberUntilGenerator( operatorReference: KtSimpleNameExpression, rangeCall: ResolvedCall<*> ) : AbstractInPrimitiveNumberRangeExpressionGenerator(codegen, operatorReference, rangeCall, isInclusiveHighBound = false) { - private val from: ReceiverValue = rangeCall.dispatchReceiver!! + private val from: ReceiverValue = rangeCall.extensionReceiver!! private val to: KtExpression = ExpressionCodegen.getSingleArgumentExpression(rangeCall)!! override fun genLowBound(): StackValue = codegen.generateReceiverValue(from, false) diff --git a/compiler/testData/codegen/box/ranges/contains/inUntil.kt b/compiler/testData/codegen/box/ranges/contains/inUntil.kt new file mode 100644 index 00000000000..126dd80728c --- /dev/null +++ b/compiler/testData/codegen/box/ranges/contains/inUntil.kt @@ -0,0 +1,29 @@ +// WITH_RUNTIME + +fun box(): String { + if (!(1 in 0 until 10)) return "Fail 1 in" + if (1 !in 0 until 10) return "Fail 1 !in" + + if (10 in 0 until 10) return "Fail 2 in" + if (!(10 !in 0 until 10)) return "Fail 2 !in" + + if (!(1.toByte() in 0.toByte() until 10.toByte())) return "Fail 1 in Byte" + if (1.toByte() !in 0.toByte() until 10.toByte()) return "Fail 1 !in Byte" + + if (10.toByte() in 0.toByte() until 10.toByte()) return "Fail 2 in Byte" + if (!(10.toByte() !in 0.toByte() until 10.toByte())) return "Fail 2 !in Byte" + + if (!(1.toShort() in 0.toShort() until 10.toShort())) return "Fail 1 in Short" + if (1.toShort() !in 0.toShort() until 10.toShort()) return "Fail 1 !in Short" + + if (10.toShort() in 0.toShort() until 10.toShort()) return "Fail 2 in Short" + if (!(10.toShort() !in 0.toShort() until 10.toShort())) return "Fail 2 !in Short" + + if (!(1.toLong() in 0.toLong() until 10.toLong())) return "Fail 1 in Long" + if (1.toLong() !in 0.toLong() until 10.toLong()) return "Fail 1 !in Long" + + if (10.toLong() in 0.toLong() until 10.toLong()) return "Fail 2 in Long" + if (!(10.toLong() !in 0.toLong() until 10.toLong())) return "Fail 2 !in Long" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/ranges/inUntil.kt b/compiler/testData/codegen/bytecodeText/ranges/inUntil.kt new file mode 100644 index 00000000000..48257a74f80 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/ranges/inUntil.kt @@ -0,0 +1,12 @@ +// WITH_RUNTIME + +fun testByte(a: Byte, x: Byte, y: Byte) = a in x until y + +fun testShort(a: Short, x: Short, y: Short) = a in x until y + +fun testInt(a: Int, x: Int, y: Int) = a in x until y + +fun testLong(a: Long, x: Long, y: Long) = a in x until y + +// 0 INVOKESTATIC kotlin/ranges/RangesKt.until +// 0 INVOKEVIRTUAL \ No newline at end of file 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 6fe8e7f11d1..7a1ef6e502d 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 @@ -13297,6 +13297,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("inUntil.kt") + public void testInUntil() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inUntil.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 4c4e5462737..b6dbac4781f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13297,6 +13297,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("inUntil.kt") + public void testInUntil() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inUntil.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 66e9cc23621..47edebbed0a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -1882,6 +1882,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inOptimizableRange.kt"); doTest(fileName); } + + @TestMetadata("inUntil.kt") + public void testInUntil() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inUntil.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/codegen/bytecodeText/statements") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 6494097b72c..c828c14de7e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13297,6 +13297,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes doTest(fileName); } + @TestMetadata("inUntil.kt") + public void testInUntil() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inUntil.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt"); 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 768fe40aab9..a8bd14b74dc 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 @@ -14977,6 +14977,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("inUntil.kt") + public void testInUntil() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inUntil.kt"); + doTest(fileName); + } + @TestMetadata("rangeContainsString.kt") public void testRangeContainsString() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/rangeContainsString.kt");