[FIR] Fix overloading of renamed jvm methods

#KT-48102 Fixed
This commit is contained in:
Andrey Zinovyev
2021-08-06 14:11:40 +03:00
committed by TeamCityServer
parent cd99c35649
commit 1b81018b69
14 changed files with 86 additions and 93 deletions
@@ -0,0 +1,13 @@
// KT-48102
// FIR_IDENTICAL
// FILE: MyCharSequence.java
public class MyCharSequence implements CharSequence {
public char charAt(int index) { return ' '; }
public int length() { return 1; }
public CharSequence subSequence(int start, int end) { return this; }
public String toString() { return " "; }
}
// FILE: CharSeq.kt
class KtCharSeq : MyCharSequence() // false-positive 'get' not implemented
@@ -0,0 +1,21 @@
package
public final class KtCharSeq : MyCharSequence {
public constructor KtCharSeq()
public open override /*1*/ /*fake_override*/ val length: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class MyCharSequence : kotlin.CharSequence {
public constructor MyCharSequence()
public open override /*1*/ val length: kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
public open override /*1*/ fun toString(): kotlin.String
}
@@ -150,14 +150,14 @@ class Y2 : X() {
fun main() {
X().remove("")
X().<!OVERLOAD_RESOLUTION_AMBIGUITY!>removeAt<!>(1)
X().removeAt(1)
val y: MutableList<String> = Y()
y.removeAt(1)
Y().remove("")
Y().<!OVERLOAD_RESOLUTION_AMBIGUITY!>removeAt<!>(1)
Y().removeAt(1)
X().remove("")
X().<!OVERLOAD_RESOLUTION_AMBIGUITY!>removeAt<!>(1)
X().removeAt(1)
}
@@ -1,32 +0,0 @@
// 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<Int>, AbstractList<Int>() {
override fun removeAt(index: Int): Int = null!!
override fun remove(element: Int): Boolean = null!!
}
abstract class D : AbstractList<Int>() {
// 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<Int>) {
a.remove(1)
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>removeAt<!>(0)
b.remove(1)
b.removeAt(0)
c.remove(1)
c.removeAt(0)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// JAVAC_EXPECTED_FILE
// FILE: A.java
abstract public class A extends B {
@@ -1,24 +0,0 @@
// KT-1730 Method which has been implemented by Java is recognized to be abstract.
// FILE: C.java
public class C implements java.lang.CharSequence {
@Override
public int length() {
return 3;
}
@Override
public char charAt(int index) {
return 48;
}
@Override
public CharSequence subSequence(int start, int end) {
return "ab";
}
@Override
public String toString() {
return "abc";
}
}
// FILE: T.kt
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class T<!> : C()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// KT-1730 Method which has been implemented by Java is recognized to be abstract.
// FILE: C.java