mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +00:00
The problem is that `override fun remove(element: E): CollectionWithRemove<E>` seems to be illegal from Java's point of view, while it's OK for JVM These declarations have the same signature (return type is isgnored) - override fun remove(element: E): CollectionWithRemove<E> - override fun remove(element: E): Boolean When we meet such declaration we choose random declaration for fake override in synthetic class that may lead to signature clash
35 lines
1018 B
Kotlin
Vendored
35 lines
1018 B
Kotlin
Vendored
class A : Collection<Char> {
|
|
override val size: Int
|
|
get() = throw UnsupportedOperationException()
|
|
|
|
override fun contains(element: Char): Boolean {
|
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
}
|
|
|
|
override fun containsAll(elements: Collection<Char>): Boolean {
|
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
}
|
|
|
|
override fun isEmpty(): Boolean {
|
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
}
|
|
|
|
override fun iterator() = MyIterator
|
|
}
|
|
|
|
object MyIterator : Iterator<Char> {
|
|
override fun hasNext() = true
|
|
|
|
override fun next() = 'a'
|
|
}
|
|
|
|
|
|
fun box(): String {
|
|
val it: MyIterator = A().iterator()
|
|
|
|
if (!it.hasNext()) return "fail 1"
|
|
if (it.next() != 'a') return "fail 2"
|
|
|
|
return "OK"
|
|
}
|