From 5f2de9dbffaa4bdb73bae25173256530715cd092 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Wed, 2 Aug 2023 18:53:30 +0200 Subject: [PATCH] [IR] Create primitive iterators in `IrBuiltIns` This change is required to fix stdlib compilation with enabled linking via signature. All primitive iterators are considered to be builtins and are created during compile time as deserialized declarations (at least in K1). But if we meet the definition of some primitive iterator in code, for example, during stdlib compilation, we will end up with two different descriptors (deserialized and lazy) that describe the same entity. Because of that we have conflicts in symbol table: * For descriptors, we will end up with multiple IR declarations that describe the same class, but with different descriptors. With some magic compilation still works. * For signatures, we will end up with only one IR declaration in the table, but it will have wrong deserialized (instead of lazy) descriptor. In the end, this change allows us to initialize iterators in advance with correct descriptor. #KT-56230 --- .../kotlin/fir/backend/IrBuiltInsOverFir.kt | 41 +++++++++++-------- ...degenWithBytecodeInlinerTestGenerated.java | 12 ++++++ ...lineCodegenWithIrInlinerTestGenerated.java | 12 ++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++++ ...degenWithBytecodeInlinerTestGenerated.java | 12 ++++++ ...lineCodegenWithIrInlinerTestGenerated.java | 12 ++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++++ .../descriptors/IrBuiltInsOverDescriptors.kt | 21 ++++++++++ .../src/org/jetbrains/kotlin/ir/IrBuiltIns.kt | 9 ++++ .../signature/byteIteratorWithForLoop.kt | 31 ++++++++++++++ .../signature/byteIteratorWithWhileLoop.kt | 35 ++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 12 ++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++++ ...degenWithBytecodeInlinerTestGenerated.java | 12 ++++++ ...lineCodegenWithIrInlinerTestGenerated.java | 12 ++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 ++++++ ...JvmIrAgainstOldBoxInlineTestGenerated.java | 12 ++++++ ...JvmOldAgainstIrBoxInlineTestGenerated.java | 12 ++++++ 19 files changed, 289 insertions(+), 16 deletions(-) create mode 100644 compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt create mode 100644 compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt index 538426b16a3..b6c56f7dd04 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/IrBuiltInsOverFir.kt @@ -334,23 +334,32 @@ class IrBuiltInsOverFir( private fun primitiveIterator(primitiveType: PrimitiveType) = loadClass(ClassId(StandardClassIds.BASE_COLLECTIONS_PACKAGE, Name.identifier("${primitiveType.typeName}Iterator"))) - private val booleanIterator by primitiveIterator(PrimitiveType.BOOLEAN) - private val charIterator by primitiveIterator(PrimitiveType.CHAR) - private val byteIterator by primitiveIterator(PrimitiveType.BYTE) - private val shortIterator by primitiveIterator(PrimitiveType.SHORT) - private val intIterator by primitiveIterator(PrimitiveType.INT) - private val longIterator by primitiveIterator(PrimitiveType.LONG) - private val floatIterator by primitiveIterator(PrimitiveType.FLOAT) - private val doubleIterator by primitiveIterator(PrimitiveType.DOUBLE) + private val _booleanIterator by primitiveIterator(PrimitiveType.BOOLEAN) + private val _charIterator by primitiveIterator(PrimitiveType.CHAR) + private val _byteIterator by primitiveIterator(PrimitiveType.BYTE) + private val _shortIterator by primitiveIterator(PrimitiveType.SHORT) + private val _intIterator by primitiveIterator(PrimitiveType.INT) + private val _longIterator by primitiveIterator(PrimitiveType.LONG) + private val _floatIterator by primitiveIterator(PrimitiveType.FLOAT) + private val _doubleIterator by primitiveIterator(PrimitiveType.DOUBLE) - private val _booleanArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BOOLEAN, booleanIterator) - private val _charArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.CHAR, charIterator) - private val _byteArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BYTE, byteIterator) - private val _shortArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.SHORT, shortIterator) - private val _intArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.INT, intIterator) - private val _longArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.LONG, longIterator) - private val _floatArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.FLOAT, floatIterator) - private val _doubleArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.DOUBLE, doubleIterator) + override val booleanIterator: IrClassSymbol get() = _booleanIterator.klass + override val charIterator: IrClassSymbol get() = _charIterator.klass + override val byteIterator: IrClassSymbol get() = _byteIterator.klass + override val shortIterator: IrClassSymbol get() = _shortIterator.klass + override val intIterator: IrClassSymbol get() = _intIterator.klass + override val longIterator: IrClassSymbol get() = _longIterator.klass + override val floatIterator: IrClassSymbol get() = _floatIterator.klass + override val doubleIterator: IrClassSymbol get() = _doubleIterator.klass + + private val _booleanArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BOOLEAN, _booleanIterator) + private val _charArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.CHAR, _charIterator) + private val _byteArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.BYTE, _byteIterator) + private val _shortArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.SHORT, _shortIterator) + private val _intArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.INT, _intIterator) + private val _longArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.LONG, _longIterator) + private val _floatArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.FLOAT, _floatIterator) + private val _doubleArray by createPrimitiveArrayClass(kotlinIrPackage, PrimitiveType.DOUBLE, _doubleIterator) override val booleanArray: IrClassSymbol get() = _booleanArray.klass override val charArray: IrClassSymbol get() = _charArray.klass diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java index caa8d384071..f2d17c409dc 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java @@ -4342,6 +4342,18 @@ public class FirLightTreeBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated e KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithIrInlinerTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithIrInlinerTestGenerated.java index 060490a20bf..7cbca0306d7 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithIrInlinerTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxInlineCodegenWithIrInlinerTestGenerated.java @@ -4342,6 +4342,18 @@ public class FirLightTreeBlackBoxInlineCodegenWithIrInlinerTestGenerated extends KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java index 6d9013a68e6..b1f05cad0ce 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4342,6 +4342,18 @@ public class FirLightTreeSerializeCompileKotlinAgainstInlineKotlinTestGenerated KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR_SERIALIZE, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java index f4ef13982fc..31e4f49bc2d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java @@ -4342,6 +4342,18 @@ public class FirPsiBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated extends KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithIrInlinerTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithIrInlinerTestGenerated.java index f3ee114dbcd..e2b4f838492 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithIrInlinerTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxInlineCodegenWithIrInlinerTestGenerated.java @@ -4342,6 +4342,18 @@ public class FirPsiBlackBoxInlineCodegenWithIrInlinerTestGenerated extends Abstr KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java index e45de91eef7..712bb80d7c2 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4342,6 +4342,18 @@ public class FirPsiSerializeCompileKotlinAgainstInlineKotlinTestGenerated extend KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR_SERIALIZE, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/descriptors/IrBuiltInsOverDescriptors.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/descriptors/IrBuiltInsOverDescriptors.kt index 39bbc986924..89476290d47 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/descriptors/IrBuiltInsOverDescriptors.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/descriptors/IrBuiltInsOverDescriptors.kt @@ -425,6 +425,27 @@ class IrBuiltInsOverDescriptors( override val primitiveIrTypesWithComparisons = listOf(charType, byteType, shortType, intType, floatType, longType, doubleType) override val primitiveFloatingPointIrTypes = listOf(floatType, doubleType) + override val byteIterator = getPrimitiveIterator(PrimitiveType.BYTE) + override val charIterator = getPrimitiveIterator(PrimitiveType.CHAR) + override val shortIterator = getPrimitiveIterator(PrimitiveType.SHORT) + override val intIterator = getPrimitiveIterator(PrimitiveType.INT) + override val longIterator = getPrimitiveIterator(PrimitiveType.LONG) + override val floatIterator = getPrimitiveIterator(PrimitiveType.FLOAT) + override val doubleIterator = getPrimitiveIterator(PrimitiveType.DOUBLE) + override val booleanIterator = getPrimitiveIterator(PrimitiveType.BOOLEAN) + + private fun getPrimitiveIterator(kind: PrimitiveType): IrClassSymbol { + val iteratorName = FqName("kotlin.collections.${kind.typeName}Iterator") + return builtIns.getBuiltInClassByFqName(iteratorName).let { + val iteratorIrSymbol = it.toIrSymbol() + it.unsubstitutedMemberScope + .getContributedFunctions(Name.identifier("next"), NoLookupLocation.FROM_BACKEND) + .single() + .toIrSymbol() + iteratorIrSymbol + } + } + override val byteArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.BYTE).toIrSymbol() override val charArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.CHAR).toIrSymbol() override val shortArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.SHORT).toIrSymbol() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt index 7f34aec5ffb..4f5e395181a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrBuiltIns.kt @@ -102,6 +102,15 @@ abstract class IrBuiltIns { abstract val primitiveIrTypesWithComparisons: List abstract val primitiveFloatingPointIrTypes: List + abstract val byteIterator: IrClassSymbol + abstract val charIterator: IrClassSymbol + abstract val shortIterator: IrClassSymbol + abstract val intIterator: IrClassSymbol + abstract val longIterator: IrClassSymbol + abstract val floatIterator: IrClassSymbol + abstract val doubleIterator: IrClassSymbol + abstract val booleanIterator: IrClassSymbol + abstract val byteArray: IrClassSymbol abstract val charArray: IrClassSymbol abstract val shortArray: IrClassSymbol diff --git a/compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt b/compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt new file mode 100644 index 00000000000..0f0a2628d31 --- /dev/null +++ b/compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt @@ -0,0 +1,31 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_K2: JVM_IR +// IGNORE_BACKEND_K2_MULTI_MODULE: JVM_IR JVM_IR_SERIALIZE +// ALLOW_KOTLIN_PACKAGE +// Note: order of files is important + +// MODULE: kotlin_stdlib +// FILE: _Arrays.kt +package kotlin.collections + +public inline fun ByteArray.customFirst(predicate: (Byte) -> Boolean): Byte { + for (element in this) if (predicate(element)) return element + throw NoSuchElementException("Array contains no element matching the predicate.") +} + +// FILE: PrimitiveIterators.kt +package kotlin.collections + +public abstract class ByteIterator : Iterator { + override final fun next() = nextByte() + + /** Returns the next value in the sequence without boxing. */ + public abstract fun nextByte(): Byte +} + +// Module: main(kotlin_stdlib) +// FILE: main.kt +fun box(): String { + byteArrayOf(1, 2, 3).customFirst { it == 1.toByte() } + return "OK" +} diff --git a/compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt b/compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt new file mode 100644 index 00000000000..05a1b5fbbce --- /dev/null +++ b/compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt @@ -0,0 +1,35 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_K2: JVM_IR +// IGNORE_BACKEND_K2_MULTI_MODULE: JVM_IR JVM_IR_SERIALIZE +// ALLOW_KOTLIN_PACKAGE +// Note: order of files is important + +// MODULE: kotlin_stdlib +// FILE: _Arrays.kt +package kotlin.collections + +public inline fun ByteArray.customFirst(predicate: (Byte) -> Boolean): Byte { + val iter = this.iterator() + while (iter.hasNext()) { + val element = iter.next() + if (predicate(element)) return element + } + throw NoSuchElementException("Array contains no element matching the predicate.") +} + +// FILE: PrimitiveIterators.kt +package kotlin.collections + +public abstract class ByteIterator : Iterator { + override final fun next() = nextByte() + + /** Returns the next value in the sequence without boxing. */ + public abstract fun nextByte(): Byte +} + +// MODULE: main(kotlin_stdlib) +// FILE: main.kt +fun box(): String { + byteArrayOf(1, 2, 3).customFirst { it == 1.toByte() } + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index 552d86259b3..ed1ef417ae6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -4294,6 +4294,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index f5d8a2df88e..a0eeebe2bf7 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4294,6 +4294,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java index 223e354fbe2..530e7a50983 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated.java @@ -4342,6 +4342,18 @@ public class IrBlackBoxInlineCodegenWithBytecodeInlinerTestGenerated extends Abs KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithIrInlinerTestGenerated.java index 86c0af0ca7c..8a617f63f2a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenWithIrInlinerTestGenerated.java @@ -4342,6 +4342,18 @@ public class IrBlackBoxInlineCodegenWithIrInlinerTestGenerated extends AbstractI KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 2f117383d27..88e72e365c9 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4342,6 +4342,18 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java index 89277726769..df00dd75837 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4342,6 +4342,18 @@ public class IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends Ab KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index 0409b294cf6..42b3fa97675 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -4342,6 +4342,18 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index cdc8aa8aea9..e74c3860cdb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -4294,6 +4294,18 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/signature"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR, true); } + @Test + @TestMetadata("byteIteratorWithForLoop.kt") + public void testByteIteratorWithForLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithForLoop.kt"); + } + + @Test + @TestMetadata("byteIteratorWithWhileLoop.kt") + public void testByteIteratorWithWhileLoop() throws Exception { + runTest("compiler/testData/codegen/boxInline/signature/byteIteratorWithWhileLoop.kt"); + } + @Test @TestMetadata("inProjectionSubstitution.kt") public void testInProjectionSubstitution() throws Exception {