mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +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
30 lines
1.0 KiB
Kotlin
30 lines
1.0 KiB
Kotlin
trait Addable {
|
|
fun add(s: String): Boolean = true
|
|
}
|
|
|
|
class C : Addable, List<String> {
|
|
override fun size(): Int = null!!
|
|
override fun isEmpty(): Boolean = null!!
|
|
override fun contains(o: Any?): Boolean = null!!
|
|
override fun iterator(): Iterator<String> = null!!
|
|
override fun containsAll(c: Collection<Any?>): Boolean = null!!
|
|
override fun get(index: Int): String = null!!
|
|
override fun indexOf(o: Any?): Int = null!!
|
|
override fun lastIndexOf(o: Any?): Int = null!!
|
|
override fun listIterator(): ListIterator<String> = null!!
|
|
override fun listIterator(index: Int): ListIterator<String> = null!!
|
|
override fun subList(fromIndex: Int, toIndex: Int): List<String> = null!!
|
|
}
|
|
|
|
fun box(): String {
|
|
try {
|
|
val a = C()
|
|
if (!a.add("")) return "Fail 1"
|
|
if (!(a as Addable).add("")) return "Fail 2"
|
|
if (!(a as MutableList<String>).add("")) return "Fail 3"
|
|
return "OK"
|
|
} catch (e: UnsupportedOperationException) {
|
|
return "Fail: no stub method should be generated"
|
|
}
|
|
}
|