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 d899808ea3f..8bb89b3bc38 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 @@ -25067,6 +25067,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); + } } @Nested diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/mapping/MethodSignatureMapper.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/mapping/MethodSignatureMapper.kt index ce08efd6bbc..b55211048da 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/mapping/MethodSignatureMapper.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/mapping/MethodSignatureMapper.kt @@ -350,7 +350,7 @@ class MethodSignatureMapper(private val context: JvmBackendContext, private val extractTypeMappingModeFromAnnotation( declaration.suppressWildcardsMode(), type, isForAnnotationParameter = false, mapTypeAliases = false ) - ?: if (declaration.isMethodWithDeclarationSiteWildcards && type.argumentsCount() != 0) { + ?: if (declaration.isMethodWithDeclarationSiteWildcards && !declaration.isStaticInlineClassReplacement && type.argumentsCount() != 0) { TypeMappingMode.GENERIC_ARGUMENT // Render all wildcards } else { typeSystem.getOptimalModeForValueParameter(type) diff --git a/compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt b/compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt new file mode 100644 index 00000000000..6cd80eefad6 --- /dev/null +++ b/compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt @@ -0,0 +1,39 @@ +// WITH_STDLIB +// WORKS_WHEN_VALUE_CLASS +// LANGUAGE: +ValueClasses +// IGNORE_BACKEND: JVM + +OPTIONAL_JVM_INLINE_ANNOTATION +value class IC1(val list: MutableList) : MutableList by list + +OPTIONAL_JVM_INLINE_ANNOTATION +value class IC2(val x: Int) : MutableCollection { + override val size: Int + get() = TODO("Not yet implemented") + + override fun clear() = TODO() + override fun addAll(elements: Collection) = true + override fun add(element: T) = TODO() + override fun isEmpty() = TODO() + override fun iterator() = TODO() + override fun retainAll(elements: Collection) = TODO() + override fun removeAll(elements: Collection) = TODO() + override fun remove(element: T) = TODO() + override fun containsAll(elements: Collection) = TODO() + override fun contains(element: T) = TODO() +} + +OPTIONAL_JVM_INLINE_ANNOTATION +value class IC3(val map: MutableMap) : MutableMap by map + +fun box(): String { + val inlineList = IC1(mutableListOf("a1")).also { it.addAll(0, listOf("a2", "a3")) } + if (inlineList.list != listOf("a2", "a3", "a1")) return "Fail 1" + + if (!IC2(1).addAll(setOf("b"))) return "Fail 2" + + val inlineMap = IC3(mutableMapOf("a" to "b")).also { it.putAll(mapOf("b" to "c", "c" to "d")) } + if (inlineMap.map != mapOf("a" to "b", "b" to "c", "c" to "d")) return "Fail 3" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableCollection_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableCollection_ir.txt index 8343cb8ca4e..6a166009439 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableCollection_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableCollection_ir.txt @@ -5,7 +5,7 @@ public final class InlineMutableCollection { public method add(p0: java.lang.Object): boolean public static method add-impl(p0: java.util.Collection, p1: java.lang.Object): boolean public method addAll(p0: java.util.Collection): boolean - public static method addAll-impl(p0: InlineMutableCollection, p1: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.Collection, p1: java.util.Collection): boolean public synthetic final static method box-impl(p0: java.util.Collection): InlineMutableCollection public method clear(): void public static method clear-impl(p0: java.util.Collection): void diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableList_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableList_ir.txt index f5ce6e130b4..666641eddb4 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableList_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableList_ir.txt @@ -8,8 +8,8 @@ public final class InlineMutableList { public static method add-impl(p0: java.util.List, p1: java.lang.Object): boolean public method addAll(p0: int, p1: java.util.Collection): boolean public method addAll(p0: java.util.Collection): boolean - public static method addAll-impl(p0: InlineMutableList, p1: int, p2: java.util.Collection): boolean - public static method addAll-impl(p0: InlineMutableList, p1: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.List, p1: int, p2: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.List, p1: java.util.Collection): boolean public synthetic final static method box-impl(p0: java.util.List): InlineMutableList public method clear(): void public static method clear-impl(p0: java.util.List): void diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableMap_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableMap_ir.txt index 4bce83683fb..798a512c951 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableMap_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableMap_ir.txt @@ -32,7 +32,7 @@ public final class InlineMutableMap { public method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object public static method put-impl(p0: java.util.Map, p1: java.lang.Object, p2: java.lang.Object): java.lang.Object public method putAll(p0: java.util.Map): void - public static method putAll-impl(p0: InlineMutableMap, p1: java.util.Map): void + public static method putAll-impl(p0: java.util.Map, p1: java.util.Map): void public method remove(p0: java.lang.Object): java.lang.Object public static method remove-impl(p0: java.util.Map, p1: java.lang.Object): java.lang.Object public synthetic bridge method size(): int diff --git a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableSet_ir.txt b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableSet_ir.txt index 825c72d9292..c01affe3426 100644 --- a/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableSet_ir.txt +++ b/compiler/testData/codegen/bytecodeListing/inlineClasses/inlineCollection/mutableSet_ir.txt @@ -5,7 +5,7 @@ public final class InlineMutableSet { public method add(p0: java.lang.Object): boolean public static method add-impl(p0: java.util.Set, p1: java.lang.Object): boolean public method addAll(p0: java.util.Collection): boolean - public static method addAll-impl(p0: InlineMutableSet, p1: java.util.Collection): boolean + public static method addAll-impl(p0: java.util.Set, p1: java.util.Collection): boolean public synthetic final static method box-impl(p0: java.util.Set): InlineMutableSet public method clear(): void public static method clear-impl(p0: java.util.Set): void 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 4be1d9bbb32..97dc8056979 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 @@ -24245,6 +24245,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); + } } @Nested 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 5b04fa7b9cd..37eafb62657 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 @@ -25067,6 +25067,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index bf16f7eed00..00e5a11ba96 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -20272,6 +20272,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public static class InlineClassCollection extends AbstractLightAnalysisModeTest { + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void ignoreInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getReplaceOptionalJvmInlineAnnotationWithReal()); + } + private void runTest(String testDataFilePath) throws Exception { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } 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 4ae1124ed82..add8da29142 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 @@ -19441,6 +19441,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index 5a1ca446103..2dd6ec4fe01 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -19459,6 +19459,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); + } } @Nested 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 26837728438..038c14b5709 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 @@ -19459,6 +19459,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); + } } @Nested 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 6a1b804df6e..462f1832f9b 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 @@ -17205,6 +17205,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest public void testInlineMapOfInlineClassGeneric() throws Exception { runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); } + + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); + } } @TestMetadata("compiler/testData/codegen/box/inlineClasses/interfaceDelegation") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 95458507c4d..496ed50ca81 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -21840,6 +21840,7 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest register("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineListOfInlineClassGeneric.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); register("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClass.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); register("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); + register("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt", TransformersFunctions.getRemoveOptionalJvmInlineAnnotation()); } @Test @@ -21888,6 +21889,13 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest // There is a registered source transformer for the testcase: TransformersFunctions.getRemoveOptionalJvmInlineAnnotation() runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMapOfInlineClassGeneric.kt"); } + + @Test + @TestMetadata("inlineMutableCollectionBulkAdd.kt") + public void testInlineMutableCollectionBulkAdd() throws Exception { + // There is a registered source transformer for the testcase: TransformersFunctions.getRemoveOptionalJvmInlineAnnotation() + runTest("compiler/testData/codegen/box/inlineClasses/inlineClassCollection/inlineMutableCollectionBulkAdd.kt"); + } } @Nested