Files
kotlin/compiler/testData/codegen/box/builtinStubMethods/MapWithAllImplementations.kt
2015-10-07 08:46:34 +03:00

29 lines
886 B
Kotlin
Vendored

class MyMap<K, V>: Map<K, V> {
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun containsKey(key: Any?): Boolean = false
override fun containsValue(value: Any?): Boolean = false
override fun get(key: Any?): V? = null
override fun keySet(): Set<K> = throw UnsupportedOperationException()
override fun values(): Collection<V> = throw UnsupportedOperationException()
override fun entrySet(): Set<Map.Entry<K, V>> = throw UnsupportedOperationException()
public fun put(key: K, value: V): V? = null
public fun remove(key: Any?): V? = null
public fun putAll(m: Map<out K, V>) {}
public fun clear() {}
}
fun box(): String {
val myMap = MyMap<String, Int>()
val map = myMap as java.util.Map<String, Int>
map.put("", 1)
map.remove("")
map.putAll(myMap)
map.clear()
return "OK"
}