[FIR] Replace single supertype scope with list of scopes of supertypes in use site scopes
This big refactoring is needed to cleanup building of overrides
mappings and prevent creating redundant intersection overrides in
cases when there is no need in them:
```kotlin
interface A {
fun foo()
}
interface B {
fun foo()
}
interface C : A, B {
override fun foo()
}
```
Before this refactoring there was next override tree:
C.foo
intersection override (A.foo, B.foo)
A.foo
B.foo
Also this commit fixes special mapping of overrides in jvm scopes
for declarations which have kotlin builtins in supertypes with
special java mapping rules (collections, for example)
This commit is contained in:
-85
@@ -1,85 +0,0 @@
|
||||
// FILE: CollectionStringImpl.java
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class CollectionStringImpl implements Collection<String> {
|
||||
@Override
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Iterator<String> iterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
return new Object[0];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends String> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
|
||||
public boolean contains(String o) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test(x: CollectionStringImpl) {
|
||||
x.<!OVERLOAD_RESOLUTION_AMBIGUITY!>contains<!>("")
|
||||
(x as Collection<String>).contains("")
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: CollectionStringImpl.java
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
+4
-4
@@ -12,10 +12,10 @@ abstract class KA : A() {
|
||||
}
|
||||
|
||||
fun foo(a: A, ka: KA) {
|
||||
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>contains<!>("")
|
||||
a.<!NONE_APPLICABLE!>contains<!>(1)
|
||||
"" <!OVERLOAD_RESOLUTION_AMBIGUITY!>in<!> a
|
||||
1 <!NONE_APPLICABLE!>in<!> a
|
||||
a.contains("")
|
||||
a.contains(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
|
||||
"" in a
|
||||
<!ARGUMENT_TYPE_MISMATCH!>1<!> in a
|
||||
|
||||
ka.contains("")
|
||||
ka.contains(<!ARGUMENT_TYPE_MISMATCH!>1<!>)
|
||||
|
||||
Vendored
-25
@@ -1,25 +0,0 @@
|
||||
// FILE: AImpl.java
|
||||
|
||||
abstract public class AImpl {
|
||||
public char charAt(int index) {
|
||||
return '1';
|
||||
}
|
||||
|
||||
public final int length() { return 1; }
|
||||
}
|
||||
|
||||
// FILE: A.java
|
||||
public class A extends AImpl implements CharSequence {
|
||||
public CharSequence subSequence(int start, int end) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: X.kt
|
||||
<!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>class X<!> : A()
|
||||
|
||||
fun main() {
|
||||
val x = X()
|
||||
x[0]
|
||||
x.length
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// FILE: AImpl.java
|
||||
|
||||
abstract public class AImpl {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface C : A {
|
||||
abstract override fun foo()
|
||||
}
|
||||
|
||||
interface D : A
|
||||
|
||||
// Fake override Z#foo should be abstract
|
||||
<!MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED!>class Z<!> : B, C, D
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ interface T {
|
||||
}
|
||||
|
||||
class G : C(), T {
|
||||
override fun foo() {} //should be an error "cannot infer visibility"; for now 'public' is inferred in such cases
|
||||
override fun <!CANNOT_CHANGE_ACCESS_PRIVILEGE!>foo<!>() {} //should be an error "cannot infer visibility"; for now 'public' is inferred in such cases
|
||||
}
|
||||
|
||||
open class A {
|
||||
|
||||
Reference in New Issue
Block a user