Files
kotlin-fork/compiler/testData/codegen/box/collections/removeClashJava.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

33 lines
958 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
// FILE: removeClashJava.kt
class Queue<T>() : Collection<T> {
override val size: Int = 1
override fun contains(element: T): Boolean = TODO()
override fun containsAll(elements: Collection<T>): Boolean = TODO()
override fun isEmpty(): Boolean = TODO()
override fun iterator(): Iterator<T> = TODO()
fun remove(v: Any?): Any? = v
}
fun box(): String {
val q = Queue<String>()
J.testRemove(q)
return q.remove("OK") as String
}
// FILE: J.java
import java.util.Collection;
public class J {
public static void testRemove(Collection<String> c) {
try {
c.remove("");
throw new AssertionError("c.remove(...) should throw UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
} catch (Throwable e) {
throw new AssertionError("c.remove(...) should throw UnsupportedOperationException");
}
}
}