K2: resolve remove(Int) clash in JavaOverrideChecker

In Kotlin subclasses of `MutableCollection<Int>`, the method
`remove(Int)` has its argument boxed, so that it wouldn't clash with the
method from `java.util.List`. So `JavaOverrideChecker` should understand
that a Java method `boolean remove(java.lang.Integer)` overrides it,
otherwise platform declaration clash was reported.

The code is adapted from `forceSingleValueParameterBoxing` in K1's
`methodSignatureMapping.kt`.

The test has been moved and adapted from diagnostic to codegen box
tests, to check correct backend execution + runtime.

 #KT-62316 Fixed
This commit is contained in:
Alexander Udalov
2023-10-06 12:33:55 +02:00
committed by Space Team
parent 8e023edc4f
commit 2788dcb5ff
17 changed files with 203 additions and 268 deletions
@@ -21231,12 +21231,6 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAt.kt");
}
@Test
@TestMetadata("removeAtInt.kt")
public void testRemoveAtInt() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt");
}
@Test
@TestMetadata("sizeFromKotlinOverriddenInJava.kt")
public void testSizeFromKotlinOverriddenInJava() throws Exception {
@@ -7427,6 +7427,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/collections/removeAtInt.kt");
}
@Test
@TestMetadata("removeAtIntOverrideInJava.kt")
public void testRemoveAtIntOverrideInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeAtIntOverrideInJava.kt");
}
@Test
@TestMetadata("removeAtIntOverrideInJava2.kt")
public void testRemoveAtIntOverrideInJava2() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeAtIntOverrideInJava2.kt");
}
@Test
@TestMetadata("removeClash.kt")
public void testRemoveClash() throws Exception {
@@ -7661,6 +7661,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/collections/removeAtInt.kt");
}
@Test
@TestMetadata("removeAtIntOverrideInJava.kt")
public void testRemoveAtIntOverrideInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeAtIntOverrideInJava.kt");
}
@Test
@TestMetadata("removeAtIntOverrideInJava2.kt")
public void testRemoveAtIntOverrideInJava2() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeAtIntOverrideInJava2.kt");
}
@Test
@TestMetadata("removeClash.kt")
public void testRemoveClash() throws Exception {
@@ -7661,6 +7661,18 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/collections/removeAtInt.kt");
}
@Test
@TestMetadata("removeAtIntOverrideInJava.kt")
public void testRemoveAtIntOverrideInJava() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeAtIntOverrideInJava.kt");
}
@Test
@TestMetadata("removeAtIntOverrideInJava2.kt")
public void testRemoveAtIntOverrideInJava2() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeAtIntOverrideInJava2.kt");
}
@Test
@TestMetadata("removeClash.kt")
public void testRemoveClash() throws Exception {