mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +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
31 lines
1.4 KiB
Kotlin
Vendored
31 lines
1.4 KiB
Kotlin
Vendored
interface ImmutableCollection<out E> : Collection<E> {
|
|
fun add(element: @UnsafeVariance E): ImmutableCollection<E>
|
|
fun addAll(elements: Collection<@UnsafeVariance E>): ImmutableCollection<E>
|
|
fun remove(element: @UnsafeVariance E): ImmutableCollection<E>
|
|
}
|
|
|
|
class ImmutableCollectionmpl<E> : ImmutableCollection<E> {
|
|
override val size: Int
|
|
get() = throw UnsupportedOperationException()
|
|
|
|
override fun contains(element: E): Boolean {
|
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
}
|
|
|
|
override fun containsAll(elements: Collection<E>): 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(): Iterator<E> {
|
|
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
}
|
|
|
|
override fun add(element: E): ImmutableCollection<E> = this
|
|
override fun addAll(elements: Collection<E>): ImmutableCollection<E> = this
|
|
override fun remove(element: E): ImmutableCollection<E> = this
|
|
}
|