Setup default values for type-safe bridges
#KT-9973 In Progress
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
private object EmptyList : List<Nothing> {
|
||||
override fun contains(element: Nothing): Boolean = false
|
||||
override fun containsAll(elements: Collection<Nothing>): Boolean = elements.isEmpty()
|
||||
override fun indexOf(element: Nothing): Int = -2
|
||||
override fun lastIndexOf(element: Nothing): Int = -2
|
||||
|
||||
override val size: Int get() = 0
|
||||
override fun isEmpty(): Boolean = true
|
||||
|
||||
override fun iterator(): Iterator<Nothing> = throw UnsupportedOperationException()
|
||||
override fun get(index: Int): Nothing = throw UnsupportedOperationException()
|
||||
override fun listIterator(): ListIterator<Nothing> = throw UnsupportedOperationException()
|
||||
override fun listIterator(index: Int): ListIterator<Nothing> = throw UnsupportedOperationException()
|
||||
override fun subList(fromIndex: Int, toIndex: Int): List<Nothing> = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val n = EmptyList as List<Any?>
|
||||
|
||||
if (n.contains(null)) return "fail 1"
|
||||
if (n.indexOf(null) != -1) return "fail 2"
|
||||
if (n.lastIndexOf(null) != -1) return "fail 3"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
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"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
private object EmptyStringMap : Map<String, Nothing> {
|
||||
override val size: Int get() = 0
|
||||
override fun isEmpty(): Boolean = true
|
||||
|
||||
override fun containsKey(key: String): Boolean = false
|
||||
override fun containsValue(value: Nothing): Boolean = false
|
||||
override fun get(key: String): 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 = EmptyStringMap 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"
|
||||
}
|
||||
Reference in New Issue
Block a user