Ensure that no range instance is created for 'x in array.indices'
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val ints = intArrayOf(1, 2, 3)
|
||||
val objs = arrayOf(1, 2, 3)
|
||||
|
||||
val i1 = 1
|
||||
|
||||
fun box(): String {
|
||||
// NB partially const-folded in JVM BE
|
||||
if (!(1 in ints.indices)) return "Fail 1 in IntArray.indices"
|
||||
if (1 !in ints.indices) return "Fail 1 !in IntArray.indices"
|
||||
if (!(1 in objs.indices)) return "Fail 1 in Array.indices"
|
||||
if (1 !in objs.indices) return "Fail 1 !in Array.indices"
|
||||
|
||||
if (!(i1 in ints.indices)) return "Fail i1 in IntArray.indices"
|
||||
if (i1 !in ints.indices) return "Fail i1 !in IntArray.indices"
|
||||
if (!(i1 in objs.indices)) return "Fail i1 in Array.indices"
|
||||
if (i1 !in objs.indices) return "Fail i1 !in Array.indices"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun testPrimitiveArray(i: Int, ints: IntArray) = i in ints.indices
|
||||
|
||||
fun testObjectArray(i: Int, xs: Array<Any>) = i in xs.indices
|
||||
|
||||
// 0 INVOKESTATIC kotlin/collections/ArraysKt.getIndices
|
||||
// 0 INVOKEVIRTUAL kotlin/ranges/IntRange.contains
|
||||
// 2 ARRAYLENGTH
|
||||
+6
@@ -13183,6 +13183,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inArrayIndices.kt")
|
||||
public void testInArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequence.kt")
|
||||
public void testInCharSequence() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequence.kt");
|
||||
|
||||
@@ -13183,6 +13183,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inArrayIndices.kt")
|
||||
public void testInArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequence.kt")
|
||||
public void testInCharSequence() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequence.kt");
|
||||
|
||||
@@ -1859,6 +1859,12 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inArrayIndices.kt")
|
||||
public void testInArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inComparableRangeLiteral.kt")
|
||||
public void testInComparableRangeLiteral() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inComparableRangeLiteral.kt");
|
||||
|
||||
@@ -13183,6 +13183,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inArrayIndices.kt")
|
||||
public void testInArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequence.kt")
|
||||
public void testInCharSequence() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequence.kt");
|
||||
|
||||
@@ -14791,6 +14791,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inArrayIndices.kt")
|
||||
public void testInArrayIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inArrayIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequence.kt")
|
||||
public void testInCharSequence() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequence.kt");
|
||||
|
||||
Reference in New Issue
Block a user