Files
kotlin-fork/compiler/testData/codegen/box/jvm8/javaDefaults/kt40920_map.kt
T
Kirill Rakhman 3b841dcb98 [FIR] Don't remove subsumed members from intersection overrides's overriddens
This fixes a bunch of missing overridden symbols in IR.
This is also required for fixing KT-59921 in the following commit
where we need to keep all overridden symbols of intersection overrides
so that we can enhance them properly.

#KT-57300 Fixed
#KT-57299 Fixed
#KT-59921
#KT-57300
#KT-62788
#KT-64271
#KT-64382
2024-01-31 11:16:50 +00:00

77 lines
1.6 KiB
Kotlin
Vendored

// !JVM_DEFAULT_MODE: disable
// JVM_TARGET: 1.8
// TARGET_BACKEND: JVM
// WITH_STDLIB
// FULL_JDK
// FILE: main.kt
var result = ""
interface A<K, V> : MutableMap<K, V>
interface Left<K, V> : A<K, V>
interface Right<K, V> : A<K, V> {
override fun remove(key: K): V? {
result += key.toString() + ";"
return null
}
override public fun getOrDefault(key: K, defaultValue: V): V {
result += key.toString() + ";"
return defaultValue
}
}
internal class MyMap : Left<String, String>, Right<String, String> {
override val size: Int
get() = null!!
override fun isEmpty(): Boolean {
return true
}
override fun containsKey(key: String): Boolean {
return false
}
override fun containsValue(value: String): Boolean {
return false
}
override fun get(key: String): String? {
TODO("Not yet implemented")
}
override fun put(key: String, value: String): String? {
result += "$key=$value;"
return null
}
override fun putAll(from: Map<out String, String>) {
}
override fun clear() {}
override val keys: MutableSet<String>
get() = null!!
override val values: MutableCollection<String>
get() = null!!
override val entries: MutableSet<MutableMap.MutableEntry<String, String>>
get() = null!!
}
fun box(): String {
val map = MyMap()
map["O"] = "fail"
map.remove("O")
val value = map.getOrDefault("O", "OK")
if (result != "O=fail;O;O;") return "fail 3: $result"
return value
}