Files
kotlin-fork/compiler/testData/codegen/box/builtinStubMethods/nonTrivialSubstitution.kt
T
Dmitry Petrov 6cb0e5151c KT-9377 Support is-checks for read-only collections
Intrinsics for is/as/as? with mutable Kotlin collections and related types.
2015-10-02 15:17:00 +03:00

20 lines
567 B
Kotlin
Vendored

import java.util.ArrayList
class MyCollection<T> : Collection<List<Iterator<T>>> {
override fun iterator() = null!!
override fun size(): Int = null!!
override fun isEmpty(): Boolean = null!!
override fun contains(o: Any?): Boolean = null!!
override fun containsAll(c: Collection<Any?>): 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"
}
}