Files
kotlin-fork/compiler/testData/codegen/box/specialBuiltins/emptyMap.kt
T
Mikhail Glukhikh 672b5ba0d7 K2/Java: implement platform-dependent function filtering in JvmMappedScope
We drop Kotlin function 'remove' or 'getOrDefault' from JvmMappedScope,
if it has platform-dependent annotation, and the bound Java class scope
does not contain a function with the same signature.

#KT-57268 Fixed
2024-01-30 19:44:00 +00:00

23 lines
699 B
Kotlin
Vendored

private object EmptyMap : Map<Any, Nothing> {
override val size: Int get() = 0
override fun isEmpty(): Boolean = true
override fun containsKey(key: Any): Boolean = false
override fun containsValue(value: Nothing): Boolean = false
override fun get(key: Any): Nothing? = null
override val entries: Set<Map.Entry<String, Nothing>> get() = null!!
override val keys: Set<String> get() = null!!
override val values: Collection<Nothing> get() = null!!
}
fun box(): String {
val n = EmptyMap as Map<Any?, Any?>
if (n.get(null) != null) return "fail 1"
if (n.containsKey(null)) return "fail 2"
if (n.containsValue(null)) return "fail 3"
return "OK"
}