Ensure that {Collection, CharSequence}.indices intrinsic works with 'in'
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val cs = "123"
|
||||
|
||||
val i1 = 1
|
||||
|
||||
fun box(): String {
|
||||
// NB partially const-folded in JVM BE
|
||||
if (!(1 in cs.indices)) return "Fail 1 in CharSequence.indices"
|
||||
if (1 !in cs.indices) return "Fail 1 !in CharSequence.indices"
|
||||
|
||||
if (!(i1 in cs.indices)) return "Fail i1 in CharSequence.indices"
|
||||
if (i1 !in cs.indices) return "Fail i1 !in CharSequence.indices"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
val xs = listOf(1, 2, 3)
|
||||
|
||||
val i1 = 1
|
||||
|
||||
fun box(): String {
|
||||
// NB partially const-folded in JVM BE
|
||||
if (!(1 in xs.indices)) return "Fail 1 in Collection.indices"
|
||||
if (1 !in xs.indices) return "Fail 1 !in Collection.indices"
|
||||
|
||||
if (!(i1 in xs.indices)) return "Fail i1 in Collection.indices"
|
||||
if (i1 !in xs.indices) return "Fail i1 !in Collection.indices"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun testCharSequence(i: Int, cs: CharSequence) = i in cs.indices
|
||||
|
||||
// 0 INVOKESTATIC kotlin/text/StringsKt.getIndices
|
||||
// 0 INVOKEVIRTUAL kotlin/ranges/IntRange.contains
|
||||
// 1 INVOKEINTERFACE java/lang/CharSequence.length
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun testCollection(i: Int, xs: List<Any>) = i in xs.indices
|
||||
|
||||
// 0 INVOKESTATIC kotlin/collections/CollectionsKt.getIndices
|
||||
// 0 INVOKEVIRTUAL kotlin/ranges/IntRange.contains
|
||||
// 1 INVOKEINTERFACE java/util/Collection.size
|
||||
+12
@@ -13195,6 +13195,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequenceIndices.kt")
|
||||
public void testInCharSequenceIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequenceIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCollectionIndices.kt")
|
||||
public void testInCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inComparableRange.kt")
|
||||
public void testInComparableRange() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inComparableRange.kt");
|
||||
|
||||
@@ -13195,6 +13195,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequenceIndices.kt")
|
||||
public void testInCharSequenceIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequenceIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCollectionIndices.kt")
|
||||
public void testInCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inComparableRange.kt")
|
||||
public void testInComparableRange() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inComparableRange.kt");
|
||||
|
||||
@@ -1865,6 +1865,18 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequenceIndices.kt")
|
||||
public void testInCharSequenceIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inCharSequenceIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCollectionIndices.kt")
|
||||
public void testInCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inComparableRangeLiteral.kt")
|
||||
public void testInComparableRangeLiteral() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeText/ranges/inComparableRangeLiteral.kt");
|
||||
|
||||
@@ -13195,6 +13195,18 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequenceIndices.kt")
|
||||
public void testInCharSequenceIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequenceIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCollectionIndices.kt")
|
||||
public void testInCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inComparableRange.kt")
|
||||
public void testInComparableRange() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inComparableRange.kt");
|
||||
|
||||
+12
@@ -14803,6 +14803,18 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCharSequenceIndices.kt")
|
||||
public void testInCharSequenceIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCharSequenceIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inCollectionIndices.kt")
|
||||
public void testInCollectionIndices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inCollectionIndices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inComparableRange.kt")
|
||||
public void testInComparableRange() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/ranges/contains/inComparableRange.kt");
|
||||
|
||||
Reference in New Issue
Block a user