Fix addAll & putAll invocations on inline mutable collections
^KT-54950: Fixed
This commit is contained in:
committed by
teamcity
parent
8fc787d6df
commit
e0c13e5276
+6
@@ -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
|
||||
|
||||
+1
-1
@@ -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)
|
||||
|
||||
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// WITH_STDLIB
|
||||
// WORKS_WHEN_VALUE_CLASS
|
||||
// LANGUAGE: +ValueClasses
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class IC1<T>(val list: MutableList<T>) : MutableList<T> by list
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class IC2<T>(val x: Int) : MutableCollection<T> {
|
||||
override val size: Int
|
||||
get() = TODO("Not yet implemented")
|
||||
|
||||
override fun clear() = TODO()
|
||||
override fun addAll(elements: Collection<T>) = true
|
||||
override fun add(element: T) = TODO()
|
||||
override fun isEmpty() = TODO()
|
||||
override fun iterator() = TODO()
|
||||
override fun retainAll(elements: Collection<T>) = TODO()
|
||||
override fun removeAll(elements: Collection<T>) = TODO()
|
||||
override fun remove(element: T) = TODO()
|
||||
override fun containsAll(elements: Collection<T>) = TODO()
|
||||
override fun contains(element: T) = TODO()
|
||||
}
|
||||
|
||||
OPTIONAL_JVM_INLINE_ANNOTATION
|
||||
value class IC3<T>(val map: MutableMap<T, T>) : MutableMap<T, T> 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<String>(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"
|
||||
}
|
||||
Vendored
+1
-1
@@ -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
|
||||
|
||||
Vendored
+2
-2
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+6
@@ -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
|
||||
|
||||
+6
@@ -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
|
||||
|
||||
+5
@@ -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);
|
||||
}
|
||||
|
||||
+6
@@ -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
|
||||
|
||||
+6
@@ -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
|
||||
|
||||
+6
@@ -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
|
||||
|
||||
+5
@@ -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")
|
||||
|
||||
+8
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user