JVM_IR KT-41915 compare Kotlin signatures when adding collection stubs

This commit is contained in:
Dmitry Petrov
2020-09-16 16:55:19 +03:00
parent 0e4bd70c29
commit fbfe56e0cc
7 changed files with 176 additions and 18 deletions
@@ -0,0 +1,33 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// 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");
}
}
}