This commit is contained in:
Igor Chevdar
2020-11-06 18:58:28 +05:00
parent 0e8cf58a35
commit 5e0f54a30b
10 changed files with 107 additions and 3 deletions
@@ -22572,6 +22572,16 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void testKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@@ -26,9 +26,8 @@ internal abstract class IndicesHandler(protected val context: CommonBackendConte
override fun build(expression: IrCall, data: ProgressionType, scopeOwner: IrSymbol): HeaderInfo? =
with(context.createIrBuilder(scopeOwner, expression.startOffset, expression.endOffset)) {
// `last = array.size - 1` (last is inclusive) for the loop `for (i in array.indices)`.
val receiver = expression.extensionReceiver!!
val last = irCall(receiver.type.sizePropertyGetter).apply {
dispatchReceiver = receiver
val last = irCall(expression.symbol.owner.extensionReceiverParameter!!.type.sizePropertyGetter).apply {
dispatchReceiver = expression.extensionReceiver!!
}.decrement()
ProgressionHeaderInfo(
@@ -0,0 +1,16 @@
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
// IGNORE_BACKEND: JVM, JVM_IR
fun <T : IntArray> test(array: T): Int {
var sum = 0
for (i in array.indices) {
sum = sum * 10 + i
}
return sum
}
fun box(): String {
if (test(intArrayOf(0, 0, 0, 0)) != 123) return "fail"
return "OK"
}
@@ -0,0 +1,19 @@
// KJS_WITH_FULL_RUNTIME
// WITH_RUNTIME
class Value<T>(val value: T) {
inline fun <R> runBlock(block: (T) -> R) = block(value)
}
fun <T> Value<Array<T>>.test() =
runBlock {
var sum = 0
for (i in it.indices)
sum = sum * 10 + i
sum
}
fun box(): String {
if (Value<Array<Int>>(Array<Int>(4) { 0 }).test() != 123) return "fail"
return "OK"
}
@@ -24343,6 +24343,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void testKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@@ -24241,6 +24241,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ForInIndices extends AbstractLightAnalysisModeTest {
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void ignoreKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@@ -24343,6 +24348,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@@ -22572,6 +22572,16 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void testKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@@ -18793,6 +18793,16 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void testKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@@ -18793,6 +18793,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void testKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")
@@ -18898,6 +18898,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
public void testKt13241_Collection() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt13241_Collection.kt");
}
@TestMetadata("kt43159_ArrayUpperBound.kt")
public void testKt43159_ArrayUpperBound() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_ArrayUpperBound.kt");
}
@TestMetadata("kt43159_GenericArray.kt")
public void testKt43159_GenericArray() throws Exception {
runTest("compiler/testData/codegen/box/ranges/forInIndices/kt43159_GenericArray.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/ranges/forInProgressionWithIndex")