Files
kotlin/compiler/testData/codegen/box/builtinStubMethods/ListIterator.kt
Alexander Udalov 35e956609a Rewrite mutable collection stub method generation
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
2014-10-27 17:17:31 +03:00

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"
}