From b31b293eef020a281fcac94ef569fd43cd638bee Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 1 Mar 2021 13:40:36 +0300 Subject: [PATCH] [FIR] Update testdata according to KT-45223 --- .../overridesBuiltinNoMagic.fir.kt | 6 ++-- .../collectionOverrides/removeAtInt.fir.kt | 32 +++++++++++++++++++ .../j+k/collectionOverrides/removeAtInt.kt | 1 - 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/overridesBuiltinNoMagic.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/overridesBuiltinNoMagic.fir.kt index a25795d18de..95bba9d8c0d 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/overridesBuiltinNoMagic.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/overridesBuiltinNoMagic.fir.kt @@ -150,14 +150,14 @@ class Y2 : X() { fun main() { X().remove("") - X().removeAt(1) + X().removeAt(1) val y: MutableList = Y() y.removeAt(1) Y().remove("") - Y().removeAt(1) + Y().removeAt(1) X().remove("") - X().removeAt(1) + X().removeAt(1) } diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt new file mode 100644 index 00000000000..9a5e740ed35 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.fir.kt @@ -0,0 +1,32 @@ +// JAVAC_EXPECTED_FILE +// FILE: A.java +abstract public class A extends B { + public Integer removeAt(int x) { } + public boolean remove(Integer x) { } +} + +// FILE: main.kt +import java.util.*; + +abstract class B : MutableList, AbstractList() { + override fun removeAt(index: Int): Int = null!! + override fun remove(element: Int): Boolean = null!! +} + +abstract class D : AbstractList() { + // removeAt() doesn't exist in java/util/AbstractList, it's a + // fake override of the method from kotlin/collections/MutableList + override fun removeAt(index: Int): Int = null!! + // AbstractList::remove() should return Int here. No fake overrides created. + // This may be a bug because the old compiler doesn't report a diagnostic here. + override fun remove(element: Int): Boolean = null!! +} + +fun main(a: A, b: B, c: ArrayList) { + a.remove(1) + a.removeAt(0) + b.remove(1) + b.removeAt(0) + c.remove(1) + c.removeAt(0) +} diff --git a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt index 581138898ae..8510bc01ac0 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectionOverrides/removeAtInt.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // JAVAC_EXPECTED_FILE // FILE: A.java abstract public class A extends B {