Files
kotlin-fork/compiler/testData/codegen/box/collections/removeAtIntOverrideInJava2.kt
T
Alexander Udalov 2788dcb5ff 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
2023-10-16 11:26:58 +00:00

44 lines
944 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
// FILE: IntOpenHashSet.java
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
public class IntOpenHashSet extends AbstractIntSet {
@Override
public boolean remove(final int k) { return false; }
@Override
public void clear() {}
@Override
public int size() { return 0; }
@Override
public Iterator<Integer> iterator() { return null; }
}
abstract class AbstractIntSet extends AbstractIntCollection implements IntSet {
@Override
public boolean remove(int k) { return false; }
}
abstract class AbstractIntCollection extends AbstractCollection<Integer> implements IntCollection {}
interface IntCollection extends Collection<Integer> {}
interface IntSet extends IntCollection, Set<Integer> {
boolean remove(int k);
}
// FILE: box.kt
fun box(): String {
val s = IntOpenHashSet()
s.remove(0)
return "OK"
}