diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index f4d95f29703..6bec77da6de 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -2635,6 +2635,58 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/builtinStubMethods/substitutedListWithExtraSuperInterface.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + public class BridgesForStubs { + @Test + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("derivedEmptyListAdd.kt") + public void testDerivedEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt"); + } + + @Test + @TestMetadata("derivedEmptyListSeveralModulesAdd.kt") + public void testDerivedEmptyListSeveralModulesAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt"); + } + + @Test + @TestMetadata("derivedEmptyStringListAdd.kt") + public void testDerivedEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt"); + } + + @Test + @TestMetadata("emptyListAdd.kt") + public void testEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt"); + } + + @Test + @TestMetadata("emptyListAddWithIndex.kt") + public void testEmptyListAddWithIndex() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt"); + } + + @Test + @TestMetadata("emptyListSet.kt") + public void testEmptyListSet() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt"); + } + + @Test + @TestMetadata("emptyStringListAdd.kt") + public void testEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index 5db0e80d916..929e4053fe9 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -430,7 +430,17 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass }.apply { copyAttributes(target) copyParametersWithErasure(this@addBridge, bridge.overridden) - body = context.createIrBuilder(symbol, startOffset, endOffset).run { irExprBody(delegatingCall(this@apply, target)) } + + // If target is a throwing stub, bridge also should just throw UnsupportedOperationException. + // Otherwise, it might throw ClassCastException when downcasting bridge argument to expected type. + // See KT-49765 + body = if (target.isThrowingStub()) { + createThrowingStubBody(context, this) + } else { + context.createIrBuilder(symbol, startOffset, endOffset).run { + irExprBody(delegatingCall(this@apply, target)) + } + } if (!bridge.overridden.returnType.isTypeParameterWithPrimitiveUpperBound()) { // The generated bridge method overrides all of the symbols which were overridden by its overrides. @@ -446,6 +456,19 @@ internal class BridgeLowering(val context: JvmBackendContext) : FileLoweringPass } } + private fun IrSimpleFunction.isThrowingStub(): Boolean { + if (this.origin != IrDeclarationOrigin.IR_BUILTINS_STUB && + this.origin != IrDeclarationOrigin.BRIDGE && + this.origin != IrDeclarationOrigin.BRIDGE_SPECIAL + ) { + return false + } + val body = this.body as? IrBlockBody ?: return false + if (body.statements.size != 1) return false + val irCall = body.statements[0] as? IrCall ?: return false + return irCall.symbol == context.ir.symbols.throwUnsupportedOperationException + } + private fun IrType.isTypeParameterWithPrimitiveUpperBound(): Boolean = isTypeParameter() && eraseTypeParameters().isPrimitiveType() diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt index bcd0e4d372d..cf6d086bde1 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/CollectionStubMethodLowering.kt @@ -150,7 +150,7 @@ internal class CollectionStubMethodLowering(val context: JvmBackendContext) : Cl valueParameters = removeAtStub.valueParameters.map { stubParameter -> stubParameter.copyWithCustomTypeSubstitution(this) { it } } - body = createThrowingStubBody(this) + body = createThrowingStubBody(context, this) } } @@ -176,7 +176,7 @@ internal class CollectionStubMethodLowering(val context: JvmBackendContext) : Cl dispatchReceiverParameter = function.dispatchReceiverParameter?.copyWithSubstitution(this, substitutionMap) extensionReceiverParameter = function.extensionReceiverParameter?.copyWithSubstitution(this, substitutionMap) valueParameters = function.valueParameters.map { it.copyWithSubstitution(this, substitutionMap) } - body = createThrowingStubBody(this) + body = createThrowingStubBody(context, this) } } @@ -192,17 +192,8 @@ internal class CollectionStubMethodLowering(val context: JvmBackendContext) : Cl function.returnType } - private fun createThrowingStubBody(function: IrSimpleFunction) = - context.createIrBuilder(function.symbol).irBlockBody { - // Function body consist only of throwing UnsupportedOperationException statement - +irCall(this@CollectionStubMethodLowering.context.ir.symbols.throwUnsupportedOperationException) - .apply { - putValueArgument(0, irString("Operation is not supported for read-only collection")) - } - } - private fun isEffectivelyOverriddenBy(superFun: IrSimpleFunction, overridingFun: IrSimpleFunction): Boolean { - // Function 'f0' is overridden by function 'f1' if all of the following conditions are met, + // Function 'f0' is overridden by function 'f1' if all the following conditions are met, // assuming type parameter Ti of 'f1' is "equal" to type parameter Si of 'f0': // - names are same; // - 'f1' has the same number of type parameters, @@ -390,3 +381,13 @@ internal class CollectionStubMethodLowering(val context: JvmBackendContext) : Cl private val IrClass.superClassChain: Sequence get() = generateSequence(this) { it.superClass } } + + +fun createThrowingStubBody(context: JvmBackendContext, function: IrSimpleFunction) = + context.createIrBuilder(function.symbol).irBlockBody { + // Function body consist only of throwing UnsupportedOperationException statement + +irCall(context.ir.symbols.throwUnsupportedOperationException) + .apply { + putValueArgument(0, irString("Operation is not supported for read-only collection")) + } + } diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt new file mode 100644 index 00000000000..4f1cabafb61 --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt @@ -0,0 +1,39 @@ +// TARGET_BACKEND: JVM +// FILE: derivedEmptyListAdd.kt + +open class EmptyListBase : List, RandomAccess { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: T): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): T = null!! + override fun indexOf(element: T): Int = -1 + override fun lastIndexOf(element: T): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +object EmptyList : EmptyListBase() + +fun box(): String { + try { + J.add() + return "Fail: no exception is thrown from J.add()" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add()", e) + } +} + +// FILE: J.java +public class J { + public static void add() { + EmptyList.INSTANCE.add(""); + } +} diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt new file mode 100644 index 00000000000..17973a1d9bf --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt @@ -0,0 +1,46 @@ +// TARGET_BACKEND: JVM + +// MODULE: lib +// FILE: RandomAccessList.kt + +abstract class RandomAccessList : List, RandomAccess + +// MODULE: main(lib) +// FILE: derivedEmptyListSeveralModulesAdd.kt + +open class EmptyListBase : RandomAccessList() { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: T): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): T = null!! + override fun indexOf(element: T): Int = -1 + override fun lastIndexOf(element: T): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +object EmptyList : EmptyListBase() + +fun box(): String { + try { + J.add() + return "Fail: no exception is thrown from J.add()" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add()", e) + } +} + +// FILE: J.java +public class J { + public static void add() { + EmptyList.INSTANCE.add(""); + } +} diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt new file mode 100644 index 00000000000..bd8355ece89 --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt @@ -0,0 +1,39 @@ +// TARGET_BACKEND: JVM +// FILE: derivedEmptyStringListAdd.kt + +open class EmptyListBase : List, RandomAccess { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: T): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): T = null!! + override fun indexOf(element: T): Int = -1 + override fun lastIndexOf(element: T): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +object EmptyStringList : EmptyListBase() + +fun box(): String { + try { + J.add() + return "Fail: no exception is thrown from J.add()" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add()", e) + } +} + +// FILE: J.java +public class J { + public static void add() { + EmptyStringList.INSTANCE.add(""); + } +} diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt new file mode 100644 index 00000000000..46278f8069e --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt @@ -0,0 +1,37 @@ +// TARGET_BACKEND: JVM +// FILE: emptyListAdd.kt + +object EmptyList : List, RandomAccess { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: Nothing): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): Nothing = null!! + override fun indexOf(element: Nothing): Int = -1 + override fun lastIndexOf(element: Nothing): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +fun box(): String { + try { + J.add() + return "Fail: no exception is thrown from J.add()" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add()", e) + } +} + +// FILE: J.java +public class J { + public static void add() { + EmptyList.INSTANCE.add(""); + } +} diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt new file mode 100644 index 00000000000..f36dcc915dd --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt @@ -0,0 +1,37 @@ +// TARGET_BACKEND: JVM +// FILE: emptyListAddWithIndex.kt + +object EmptyList : List, RandomAccess { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: Nothing): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): Nothing = null!! + override fun indexOf(element: Nothing): Int = -1 + override fun lastIndexOf(element: Nothing): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +fun box(): String { + try { + J.test() + return "Fail: no exception is thrown from J.add()" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add()", e) + } +} + +// FILE: J.java +public class J { + public static void test() { + EmptyList.INSTANCE.add(0, ""); + } +} diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt new file mode 100644 index 00000000000..498d27c6c76 --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt @@ -0,0 +1,37 @@ +// TARGET_BACKEND: JVM +// FILE: emptyListSet.kt + +object EmptyList : List, RandomAccess { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: Nothing): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): Nothing = null!! + override fun indexOf(element: Nothing): Int = -1 + override fun lastIndexOf(element: Nothing): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +fun box(): String { + try { + J.test() + return "Fail: no exception is thrown from J.add()" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add()", e) + } +} + +// FILE: J.java +public class J { + public static void test() { + EmptyList.INSTANCE.set(0, ""); + } +} diff --git a/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt new file mode 100644 index 00000000000..a67a243c97a --- /dev/null +++ b/compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt @@ -0,0 +1,40 @@ +// TARGET_BACKEND: JVM +// FULL_JDK +// FILE: emptyStringListAdd.kt + +object EmptyStringList : List { + override val size: Int get() = 0 + override fun isEmpty(): Boolean = true + override fun contains(element: String): Boolean = false + override fun containsAll(elements: Collection): Boolean = elements.isEmpty() + + override fun get(index: Int): String = null!! + override fun indexOf(element: String): Int = -1 + override fun lastIndexOf(element: String): Int = -1 + + override fun iterator(): Iterator = null!! + override fun listIterator(): ListIterator = null!! + override fun listIterator(index: Int): ListIterator = null!! + + override fun subList(fromIndex: Int, toIndex: Int): List = null!! +} + +fun box(): String { + try { + J.add42(EmptyStringList) + return "Fail: no exception is thrown from J.add42(list)" + } catch (e: UnsupportedOperationException) { + return "OK" + } catch (e: Throwable) { + throw AssertionError("Fail: incorrect exception is thrown from J.add42(list)", e) + } +} + +// FILE: J.java +import java.util.*; + +public class J { + public static void add42(List list) { + list.add(42); + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 717a2f80b0b..b7de4ef51eb 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -2557,6 +2557,58 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/builtinStubMethods/substitutedListWithExtraSuperInterface.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + public class BridgesForStubs { + @Test + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("derivedEmptyListAdd.kt") + public void testDerivedEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt"); + } + + @Test + @TestMetadata("derivedEmptyListSeveralModulesAdd.kt") + public void testDerivedEmptyListSeveralModulesAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt"); + } + + @Test + @TestMetadata("derivedEmptyStringListAdd.kt") + public void testDerivedEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt"); + } + + @Test + @TestMetadata("emptyListAdd.kt") + public void testEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt"); + } + + @Test + @TestMetadata("emptyListAddWithIndex.kt") + public void testEmptyListAddWithIndex() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt"); + } + + @Test + @TestMetadata("emptyListSet.kt") + public void testEmptyListSet() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt"); + } + + @Test + @TestMetadata("emptyStringListAdd.kt") + public void testEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 83a3678310c..c9b9b4021ee 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -2635,6 +2635,58 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/builtinStubMethods/substitutedListWithExtraSuperInterface.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + public class BridgesForStubs { + @Test + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("derivedEmptyListAdd.kt") + public void testDerivedEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt"); + } + + @Test + @TestMetadata("derivedEmptyListSeveralModulesAdd.kt") + public void testDerivedEmptyListSeveralModulesAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt"); + } + + @Test + @TestMetadata("derivedEmptyStringListAdd.kt") + public void testDerivedEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt"); + } + + @Test + @TestMetadata("emptyListAdd.kt") + public void testEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt"); + } + + @Test + @TestMetadata("emptyListAddWithIndex.kt") + public void testEmptyListAddWithIndex() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt"); + } + + @Test + @TestMetadata("emptyListSet.kt") + public void testEmptyListSet() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt"); + } + + @Test + @TestMetadata("emptyStringListAdd.kt") + public void testEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 064392438b8..97ccfe290a9 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2238,6 +2238,54 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/builtinStubMethods/substitutedListWithExtraSuperInterface.kt"); } + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BridgesForStubs extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("derivedEmptyListAdd.kt") + public void testDerivedEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListAdd.kt"); + } + + @TestMetadata("derivedEmptyListSeveralModulesAdd.kt") + public void testDerivedEmptyListSeveralModulesAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyListSeveralModulesAdd.kt"); + } + + @TestMetadata("derivedEmptyStringListAdd.kt") + public void testDerivedEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/derivedEmptyStringListAdd.kt"); + } + + @TestMetadata("emptyListAdd.kt") + public void testEmptyListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAdd.kt"); + } + + @TestMetadata("emptyListAddWithIndex.kt") + public void testEmptyListAddWithIndex() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListAddWithIndex.kt"); + } + + @TestMetadata("emptyListSet.kt") + public void testEmptyListSet() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyListSet.kt"); + } + + @TestMetadata("emptyStringListAdd.kt") + public void testEmptyStringListAdd() throws Exception { + runTest("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs/emptyStringListAdd.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 3349158de40..8f7711f8d71 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -1723,6 +1723,16 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + public class BridgesForStubs { + @Test + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index d35a1ddef49..aec3a981746 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -1765,6 +1765,16 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + public class BridgesForStubs { + @Test + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index bdf9dabbeca..2d8cf0467c5 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -1568,6 +1568,19 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt"); } + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class BridgesForStubs extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + } + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java index fb23125eae6..9088066ac8b 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeExtBlackBoxTestGenerated.java @@ -1785,6 +1785,17 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest { runTest("compiler/testData/codegen/box/builtinStubMethods/customReadOnlyIterator.kt"); } + @Nested + @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs") + @TestDataPath("$PROJECT_ROOT") + @NativeBlackBoxTestCaseGroupProvider(ExtTestCaseGroupProvider.class) + public class BridgesForStubs { + @Test + public void testAllFilesPresentInBridgesForStubs() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/builtinStubMethods/bridgesForStubs"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/builtinStubMethods/extendJavaCollections") @TestDataPath("$PROJECT_ROOT")