K2: Fix false positive NotImplemented error for size property

The problem appeared because not all of the `realOverridden` have been
collected because inside AbstractSerializableListDecorator some of the
scopes returned the same instance as direct overridden and after that
overridden tree traversal stopped without detecting real overrides.

Thus, the modality of intersection for
AbstractSerializableListDecorator::size and MutableSet::size
was incorrectly computed to ABSTRACT

The similar thing is already done at the place where we're obtaining
all overrides.
See https://github.com/JetBrains/kotlin/commit/c80cfb0fdb00323ba9b5e1dd98c5cbd0bfab6b8b#diff-182d90c9b8050557e4e2eb319a84b9a51fd0600c728dd0fce85cf6491c13e16dR152

^KT-57693 Fixed
This commit is contained in:
Denis.Zharkov
2023-04-18 14:21:57 +02:00
committed by Space Team
parent 6544220b3e
commit 4e2107abe7
7 changed files with 118 additions and 3 deletions
@@ -0,0 +1,84 @@
// FIR_IDENTICAL
// FULL_JDK
// ISSUE: KT-57693
// FILE: AbstractCollectionDecorator.java
import java.util.Collection;
import java.util.Iterator;
import java.util.function.Predicate;
public abstract class AbstractCollectionDecorator<E> implements Collection<E> {
protected Collection<E> decorated() {
return null;
}
public boolean add(E object) {
return this.decorated().add(object);
}
public boolean addAll(Collection<? extends E> coll) {
return this.decorated().addAll(coll);
}
public void clear() {
this.decorated().clear();
}
public boolean contains(Object object) {
return this.decorated().contains(object);
}
public boolean isEmpty() {
return this.decorated().isEmpty();
}
public Iterator<E> iterator() {
return this.decorated().iterator();
}
public boolean remove(Object object) {
return this.decorated().remove(object);
}
public int size() {
return this.decorated().size();
}
public Object[] toArray() {
return this.decorated().toArray();
}
public <T> T[] toArray(T[] object) {
return this.decorated().toArray(object);
}
public boolean containsAll(Collection<?> coll) {
return this.decorated().containsAll(coll);
}
public boolean removeIf(Predicate<? super E> filter) {
return this.decorated().removeIf(filter);
}
public boolean removeAll(Collection<?> coll) {
return this.decorated().removeAll(coll);
}
public boolean retainAll(Collection<?> coll) {
return this.decorated().retainAll(coll);
}
public String toString() {
return this.decorated().toString();
}
}
// FILE: AbstractSerializableListDecorator.java
public abstract class AbstractSerializableListDecorator<E> extends AbstractCollectionDecorator<E> {
}
// FILE: main.kt
import java.util.*
class UniqueArrayList<E> : AbstractSerializableListDecorator<E>(), MutableSet<E>