Files
kotlin-fork/compiler/testData/codegen/box/builtinStubMethods/inheritedImplementations.kt
T
Jiaxiang Chen afcbd76c9e Implement stub methods generation for Kotlin Immutable Collection classes.
This change is to fill the gap between Kotlin Collection
classes(immutable) and Java Collection classes(mutable), to avoid
calling an unsupported operation like remove() on an immutable class in
jvm.
2019-05-21 17:20:20 +03:00

24 lines
579 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
open class SetStringImpl {
fun add(s: String): Boolean = false
fun remove(o: String): Boolean = false
fun clear(): Unit {}
}
class S : Set<String>, SetStringImpl() {
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun contains(o: String): Boolean = false
override fun iterator(): Iterator<String> = null!!
override fun containsAll(c: Collection<String>) = false
}
fun box(): String {
val s = S() as java.util.Set<String>
s.add("")
s.remove("")
s.clear()
return "OK"
}