Rework support of Iterator.iterator optimization in ForLoopsLowering
- Fix the predicate used for finding the member function `next`: check that there's no extension receiver parameter, don't filter out abstract functions. - Do not copy iterator expression, instead change the type in all references to the iterator variable. - Fix some style issues. #KT-47171 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
1b776bd5b6
commit
157db778fd
+34
-16
@@ -9335,6 +9335,40 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForInIterator {
|
||||
@Test
|
||||
@TestMetadata("abstractNext.kt")
|
||||
public void testAbstractNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/abstractNext.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primitiveIterator.kt")
|
||||
public void testPrimitiveIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/primitiveIterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("uintIterator.kt")
|
||||
public void testUintIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/uintIterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unrelatedExtensionFunctionNext.kt")
|
||||
public void testUnrelatedExtensionFunctionNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/unrelatedExtensionFunctionNext.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -17266,22 +17300,6 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForLoop {
|
||||
@Test
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forInIterator.kt")
|
||||
public void testForInIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/forLoop/forInIterator.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+39
-42
@@ -10,20 +10,21 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.irCall
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner
|
||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCompositeImpl
|
||||
import org.jetbrains.kotlin.ir.types.classFqName
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.types.getClass
|
||||
import org.jetbrains.kotlin.ir.types.isStrictSubtypeOfClass
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.visitors.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
|
||||
val forLoopsPhase = makeIrFilePhase(
|
||||
::ForLoopsLowering,
|
||||
@@ -305,52 +306,44 @@ private class RangeLoopTransformer(
|
||||
* for (x in iterator)
|
||||
* println(x)
|
||||
* ```
|
||||
* Without this optimization, receiver type of call of `next` would be Iterator<T> instead of MyIterator, which
|
||||
* is an unnecessary boxing can be optimized out.
|
||||
* Without this optimization, receiver type of call of `next` would be Iterator<T> instead of MyIterator, which means that
|
||||
* a less specific method would be called, which could lead to unnecessary boxing of primitives or inline classes.
|
||||
*/
|
||||
private fun specializeIteratorIfPossible(irForLoopBlock: IrContainerExpression) {
|
||||
val statements = irForLoopBlock.statements
|
||||
|
||||
val iterator = statements[0] as IrVariable
|
||||
val loop = statements[1] as IrWhileLoop
|
||||
|
||||
// do optimization iff the initializer is call of `kotlin.collections.CollectionsKt.iterator`
|
||||
val initializer = iterator.initializer.safeAs<IrCall>().takeIf {
|
||||
it != null && it.symbol.owner.fqNameWhenAvailable == FqName("kotlin.collections.CollectionsKt.iterator")
|
||||
val initializer = iterator.initializer as? IrCall ?: return
|
||||
if (!initializer.symbol.owner.hasEqualFqName(STDLIB_ITERATOR_FUNCTION_FQ_NAME)) return
|
||||
|
||||
val receiverType = initializer.extensionReceiver?.type ?: return
|
||||
if (!receiverType.isStrictSubtypeOfClass(context.irBuiltIns.iteratorClass)) return
|
||||
|
||||
val receiverClass = receiverType.getClass() ?: return
|
||||
val next = receiverClass.functions.singleOrNull {
|
||||
it.name == OperatorNameConventions.NEXT &&
|
||||
it.dispatchReceiverParameter != null &&
|
||||
it.extensionReceiverParameter == null &&
|
||||
it.valueParameters.isEmpty()
|
||||
} ?: return
|
||||
|
||||
// for now, we only optimize for the case where extension receiver is a direct subclass of `kotlin.collections.Iterator`
|
||||
// we can expand the scope later, if it considered to be necessary
|
||||
val receiverType = initializer.extensionReceiver!!.type.takeIf {
|
||||
it.superTypes().any { superType ->
|
||||
superType.classFqName == FqName("kotlin.collections.Iterator")
|
||||
}
|
||||
} ?: return
|
||||
|
||||
fun IrClass.findNextFunction(): IrFunction? =
|
||||
this.functions.find {
|
||||
it.nameForIrSerialization.asString() == "next"
|
||||
&& it.valueParameters.isEmpty()
|
||||
&& it.modality != Modality.ABSTRACT
|
||||
}
|
||||
|
||||
val next = receiverType.classifierOrFail.owner.cast<IrClass>().findNextFunction() ?: return
|
||||
|
||||
val loopVariable = (loop.body as IrBlock).statements[0] as IrVariable
|
||||
val loopCondition = loop.condition as IrCall
|
||||
|
||||
iterator.apply {
|
||||
type = receiverType
|
||||
this.type = receiverType
|
||||
this.initializer = initializer.extensionReceiver
|
||||
}
|
||||
|
||||
loopCondition.apply {
|
||||
dispatchReceiver = initializer.extensionReceiver!!.shallowCopy()
|
||||
}
|
||||
val loop = statements[1] as IrWhileLoop
|
||||
val loopVariable = (loop.body as? IrBlock)?.statements?.firstOrNull() as? IrVariable ?: return
|
||||
val loopCondition = loop.condition as? IrCall ?: return
|
||||
loopCondition.dispatchReceiver?.type = receiverType
|
||||
|
||||
loopVariable.initializer = with(next) {
|
||||
context.createIrBuilder(symbol, startOffset, endOffset).irCall(this).apply {
|
||||
dispatchReceiver = initializer.extensionReceiver!!.shallowCopy()
|
||||
val nextCall = loopVariable.initializer as? IrCall ?: return
|
||||
loopVariable.initializer = with(nextCall) {
|
||||
IrCallImpl(
|
||||
startOffset, endOffset, type, next.symbol, typeArgumentsCount, valueArgumentsCount, origin, superQualifierSymbol
|
||||
).apply {
|
||||
copyTypeAndValueArgumentsFrom(nextCall)
|
||||
dispatchReceiver?.type = receiverType
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -471,4 +464,8 @@ private class RangeLoopTransformer(
|
||||
|
||||
return LoopVariableInfo(mainLoopVariable, mainLoopVariableIndex, loopVariableComponents, loopVariableComponentIndices)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val STDLIB_ITERATOR_FUNCTION_FQ_NAME = FqName("kotlin.collections.CollectionsKt.iterator")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ fun IrClassifierSymbol.isStrictSubtypeOfClass(superClass: IrClassSymbol): Boolea
|
||||
fun IrType.isSubtypeOfClass(superClass: IrClassSymbol): Boolean =
|
||||
this is IrSimpleType && classifier.isSubtypeOfClass(superClass)
|
||||
|
||||
fun IrType.isStrictSubtypeOfClass(superClass: IrClassSymbol): Boolean =
|
||||
this is IrSimpleType && classifier.isStrictSubtypeOfClass(superClass)
|
||||
|
||||
fun IrType.isSubtypeOf(superType: IrType, typeSystem: IrTypeSystemContext): Boolean =
|
||||
AbstractTypeChecker.isSubtypeOf(createIrTypeCheckerState(typeSystem), this, superType)
|
||||
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
|
||||
fun iterate(iterator: MyIterator): String {
|
||||
for (x in iterator) return x
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
abstract class MyIterator : Iterator<String> {
|
||||
override fun hasNext(): Boolean = true
|
||||
abstract override fun next(): String
|
||||
}
|
||||
|
||||
class MyIteratorImpl : MyIterator() {
|
||||
override fun next(): String = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = iterate(MyIteratorImpl())
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 java/util/Iterator.next
|
||||
// 1 MyIterator.next
|
||||
// 1 MyIteratorImpl.next
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
|
||||
fun myFun(iterator: MyLongIterator) {
|
||||
for (x in iterator) {
|
||||
assert(x == 42L)
|
||||
}
|
||||
}
|
||||
|
||||
class MyLongIterator : Iterator<Long> {
|
||||
private var count = 1
|
||||
override fun hasNext(): Boolean = count-- > 0
|
||||
override fun next(): Long = 42L
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
myFun(MyLongIterator())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 java/util/Iterator.next
|
||||
// 2 MyLongIterator.next
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
// CHECK_BYTECODE_LISTING
|
||||
|
||||
fun myFun(iterator: MyUIntIterator) {
|
||||
for (x in iterator) {
|
||||
@@ -25,4 +24,4 @@ fun box(): String {
|
||||
// 0 java/util/Iterator.next \(\)Ljava/lang/Object;
|
||||
// 1 MyUIntIterator.hasNext \(\)Z
|
||||
// 1 public synthetic bridge next\(\)Ljava/lang/Object;
|
||||
// 2 MyUIntIterator.next-pVg5ArA \(\)I
|
||||
// 2 MyUIntIterator.next-pVg5ArA \(\)I
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_STDLIB
|
||||
|
||||
fun iterate(iterator: MyIterator): String {
|
||||
for (x in iterator) return x
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
class MyIterator : Iterator<String> {
|
||||
@JvmName("unrelated")
|
||||
private fun String.next(): String = throw AssertionError("Should not be called")
|
||||
|
||||
override fun hasNext(): Boolean = true
|
||||
override fun next(): String = "OK"
|
||||
}
|
||||
|
||||
fun box(): String = iterate(MyIterator())
|
||||
|
||||
// CHECK_BYTECODE_TEXT
|
||||
// JVM_IR_TEMPLATES
|
||||
// 0 java/util/Iterator.next
|
||||
// 2 MyIterator.next
|
||||
@@ -1,17 +0,0 @@
|
||||
@kotlin.Metadata
|
||||
public final class ForInIteratorKt {
|
||||
// source: 'forInIterator.kt'
|
||||
public final static @org.jetbrains.annotations.NotNull method box(): java.lang.String
|
||||
public final static method myFun(@org.jetbrains.annotations.NotNull p0: MyUIntIterator): void
|
||||
}
|
||||
|
||||
@kotlin.Metadata
|
||||
public final class MyUIntIterator {
|
||||
// source: 'forInIterator.kt'
|
||||
private field count: int
|
||||
public method <init>(): void
|
||||
public method hasNext(): boolean
|
||||
public synthetic bridge method next(): java.lang.Object
|
||||
public method next-pVg5ArA(): int
|
||||
public method remove(): void
|
||||
}
|
||||
+34
-16
@@ -9215,6 +9215,40 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForInIterator {
|
||||
@Test
|
||||
@TestMetadata("abstractNext.kt")
|
||||
public void testAbstractNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/abstractNext.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primitiveIterator.kt")
|
||||
public void testPrimitiveIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/primitiveIterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("uintIterator.kt")
|
||||
public void testUintIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/uintIterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unrelatedExtensionFunctionNext.kt")
|
||||
public void testUnrelatedExtensionFunctionNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/unrelatedExtensionFunctionNext.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -16846,22 +16880,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForLoop {
|
||||
@Test
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forInIterator.kt")
|
||||
public void testForInIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/forLoop/forInIterator.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+34
-16
@@ -9335,6 +9335,40 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForInIterator {
|
||||
@Test
|
||||
@TestMetadata("abstractNext.kt")
|
||||
public void testAbstractNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/abstractNext.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primitiveIterator.kt")
|
||||
public void testPrimitiveIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/primitiveIterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("uintIterator.kt")
|
||||
public void testUintIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/uintIterator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("unrelatedExtensionFunctionNext.kt")
|
||||
public void testUnrelatedExtensionFunctionNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/unrelatedExtensionFunctionNext.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -17266,22 +17300,6 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForLoop {
|
||||
@Test
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forInIterator.kt")
|
||||
public void testForInIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/forLoop/forInIterator.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+33
-18
@@ -7173,6 +7173,39 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ForInIterator extends AbstractLightAnalysisModeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("abstractNext.kt")
|
||||
public void testAbstractNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/abstractNext.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("primitiveIterator.kt")
|
||||
public void testPrimitiveIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/primitiveIterator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("uintIterator.kt")
|
||||
public void testUintIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/uintIterator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unrelatedExtensionFunctionNext.kt")
|
||||
public void testUnrelatedExtensionFunctionNext() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/controlStructures/forInIterator/unrelatedExtensionFunctionNext.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -13929,24 +13962,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ForLoop extends AbstractLightAnalysisModeTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("forInIterator.kt")
|
||||
public void testForInIterator() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/forLoop/forInIterator.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+10
-10
@@ -6415,6 +6415,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForInIterator {
|
||||
@Test
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -13014,16 +13024,6 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForLoop {
|
||||
@Test
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+10
-10
@@ -6457,6 +6457,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForInIterator {
|
||||
@Test
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -13056,16 +13066,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class ForLoop {
|
||||
@Test
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
+13
-13
@@ -5590,6 +5590,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ForInIterator extends AbstractIrCodegenBoxWasmTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -10891,19 +10904,6 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ForLoop extends AbstractIrCodegenBoxWasmTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+12
-12
@@ -7261,6 +7261,18 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInIterator")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("codegen")
|
||||
@UseExtTestCaseGroupProvider()
|
||||
public class ForInIterator {
|
||||
@Test
|
||||
public void testAllFilesPresentInForInIterator() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/controlStructures/forInIterator"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/controlStructures/forInSequenceWithIndex")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@@ -14030,18 +14042,6 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/forLoop")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@Tag("codegen")
|
||||
@UseExtTestCaseGroupProvider()
|
||||
public class ForLoop {
|
||||
@Test
|
||||
public void testAllFilesPresentInForLoop() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/forLoop"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
|
||||
Reference in New Issue
Block a user