mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-11 00:21:29 +00:00
The main problem of the previous approach was that we were only generating erased method signatures, which was incorrect in case a class also had a member from another supertype with the same signature as the substituted one from the collection. Javac issues compilation errors when compiling Java code against such classes. Also all the needed method stub signatures were hardcoded in generateBuiltInMethodStubs() and the case of MutableListIterator was missing
26 lines
629 B
Kotlin
26 lines
629 B
Kotlin
class MyListIterator<T> : ListIterator<T> {
|
|
override fun next(): T = null!!
|
|
override fun hasNext(): Boolean = null!!
|
|
override fun hasPrevious(): Boolean = null!!
|
|
override fun previous(): T = null!!
|
|
override fun nextIndex(): Int = null!!
|
|
override fun previousIndex(): Int = null!!
|
|
}
|
|
|
|
fun expectUoe(block: () -> Any) {
|
|
try {
|
|
block()
|
|
throw AssertionError()
|
|
} catch (e: UnsupportedOperationException) {
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val list = MyListIterator<String>() as MutableListIterator<String>
|
|
|
|
expectUoe { list.set("") }
|
|
expectUoe { list.add("") }
|
|
|
|
return "OK"
|
|
}
|