Files
kotlin-fork/compiler/testData/codegen/box/builtinStubMethods/nonTrivialSubstitution.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

20 lines
593 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
class MyCollection<T> : Collection<List<Iterator<T>>> {
override fun iterator() = null!!
override val size: Int get() = null!!
override fun isEmpty(): Boolean = null!!
override fun contains(o: List<Iterator<T>>): Boolean = null!!
override fun containsAll(c: Collection<List<Iterator<T>>>): Boolean = null!!
}
fun box(): String {
val c = MyCollection<String>() as java.util.Collection<List<Iterator<String>>>
try {
c.add(ArrayList())
return "Fail"
} catch (e: UnsupportedOperationException) {
return "OK"
}
}