mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-13 00:21:28 +00:00
By default we would render 'MutableCollection<String>.addAll(Collection<String>)' as '(LCollection<String>;)' (without wildcard) because String is final and effectively it's the same as '(LCollection<? extends String>;)'. But that's wrong signature in a sense that java.util.Collection has different signature: '(LCollection<? extends E>)'. Actually the problem is much wider than collections, it concerns any Java code that uses Kotlin classes with covariant parameters without '? extends E' wildcards. Temporary solution is just to hardcode/enumerate builtin methods with special signature.
82 lines
2.1 KiB
Kotlin
Vendored
82 lines
2.1 KiB
Kotlin
Vendored
abstract class KList : MutableList<String> {
|
|
override val size: Int
|
|
get() = throw UnsupportedOperationException()
|
|
|
|
override fun isEmpty(): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun contains(o: String) = true
|
|
override fun containsAll(c: Collection<String>) = true
|
|
|
|
override fun get(index: Int): String {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun indexOf(o: String): Int {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun lastIndexOf(o: String): Int {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun iterator(): MutableIterator<String> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun add(e: String): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun remove(o: String): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun addAll(c: Collection<String>): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun addAll(index: Int, c: Collection<String>): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun removeAll(c: Collection<String>): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun retainAll(c: Collection<String>): Boolean {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun clear() {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun set(index: Int, element: String): String {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun add(index: Int, element: String) {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun removeAt(index: Int): String {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun listIterator(): MutableListIterator<String> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun listIterator(index: Int): MutableListIterator<String> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
override fun subList(fromIndex: Int, toIndex: Int): MutableList<String> {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
}
|
|
fun box() = J.foo()
|