Ensure that 'in/!in x until y' intrinsic works
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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
|
||||
+6
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user