提交 61459961 编写于 作者: D Denis Zharkov

Adjust stdlib to `isEmpty` transformation

上级 cfc9d198
...@@ -13,7 +13,7 @@ public interface Comparator<T> { ...@@ -13,7 +13,7 @@ public interface Comparator<T> {
@library @library
public abstract class AbstractCollection<E>() : MutableCollection<E> { public abstract class AbstractCollection<E>() : MutableCollection<E> {
override fun isEmpty(): Boolean = noImpl override val isEmpty: Boolean get() = noImpl
override fun contains(o: E): Boolean = noImpl override fun contains(o: E): Boolean = noImpl
override fun iterator(): MutableIterator<E> = noImpl override fun iterator(): MutableIterator<E> = noImpl
...@@ -103,7 +103,7 @@ public open class LinkedHashSet<E>( ...@@ -103,7 +103,7 @@ public open class LinkedHashSet<E>(
@library @library
public open class HashMap<K, V>(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap<K, V> { public open class HashMap<K, V>(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap<K, V> {
override val size: Int get() = noImpl override val size: Int get() = noImpl
override fun isEmpty(): Boolean = noImpl override val isEmpty: Boolean get() = noImpl
@Suppress("BASE_WITH_NULLABLE_UPPER_BOUND") @Suppress("BASE_WITH_NULLABLE_UPPER_BOUND")
override fun get(key: Any?): V? = noImpl override fun get(key: Any?): V? = noImpl
override fun containsKey(key: Any?): Boolean = noImpl override fun containsKey(key: Any?): Boolean = noImpl
......
...@@ -178,7 +178,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? { ...@@ -178,7 +178,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? {
override val groups: MatchGroupCollection = object : MatchGroupCollection { override val groups: MatchGroupCollection = object : MatchGroupCollection {
override val size: Int get() = match.size() override val size: Int get() = match.size()
override fun isEmpty(): Boolean = size() == 0 override val isEmpty: Boolean get() = size() == 0
override fun contains(o: MatchGroup?): Boolean = this.any { it == o } override fun contains(o: MatchGroup?): Boolean = this.any { it == o }
override fun containsAll(c: Collection<MatchGroup?>): Boolean = c.all({contains(it)}) override fun containsAll(c: Collection<MatchGroup?>): Boolean = c.all({contains(it)})
......
...@@ -10175,7 +10175,7 @@ public fun <T> Array<out T>.asList(): List<T> { ...@@ -10175,7 +10175,7 @@ public fun <T> Array<out T>.asList(): List<T> {
public fun BooleanArray.asList(): List<Boolean> { public fun BooleanArray.asList(): List<Boolean> {
return object : AbstractList<Boolean>(), RandomAccess { return object : AbstractList<Boolean>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Boolean): Boolean = this@asList.contains(o) override fun contains(o: Boolean): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Boolean> = this@asList.iterator() as MutableIterator<Boolean> override fun iterator(): MutableIterator<Boolean> = this@asList.iterator() as MutableIterator<Boolean>
override fun get(index: Int): Boolean = this@asList[index] override fun get(index: Int): Boolean = this@asList[index]
...@@ -10191,7 +10191,7 @@ public fun BooleanArray.asList(): List<Boolean> { ...@@ -10191,7 +10191,7 @@ public fun BooleanArray.asList(): List<Boolean> {
public fun ByteArray.asList(): List<Byte> { public fun ByteArray.asList(): List<Byte> {
return object : AbstractList<Byte>(), RandomAccess { return object : AbstractList<Byte>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Byte): Boolean = this@asList.contains(o) override fun contains(o: Byte): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Byte> = this@asList.iterator() as MutableIterator<Byte> override fun iterator(): MutableIterator<Byte> = this@asList.iterator() as MutableIterator<Byte>
override fun get(index: Int): Byte = this@asList[index] override fun get(index: Int): Byte = this@asList[index]
...@@ -10207,7 +10207,7 @@ public fun ByteArray.asList(): List<Byte> { ...@@ -10207,7 +10207,7 @@ public fun ByteArray.asList(): List<Byte> {
public fun CharArray.asList(): List<Char> { public fun CharArray.asList(): List<Char> {
return object : AbstractList<Char>(), RandomAccess { return object : AbstractList<Char>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Char): Boolean = this@asList.contains(o) override fun contains(o: Char): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Char> = this@asList.iterator() as MutableIterator<Char> override fun iterator(): MutableIterator<Char> = this@asList.iterator() as MutableIterator<Char>
override fun get(index: Int): Char = this@asList[index] override fun get(index: Int): Char = this@asList[index]
...@@ -10223,7 +10223,7 @@ public fun CharArray.asList(): List<Char> { ...@@ -10223,7 +10223,7 @@ public fun CharArray.asList(): List<Char> {
public fun DoubleArray.asList(): List<Double> { public fun DoubleArray.asList(): List<Double> {
return object : AbstractList<Double>(), RandomAccess { return object : AbstractList<Double>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Double): Boolean = this@asList.contains(o) override fun contains(o: Double): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Double> = this@asList.iterator() as MutableIterator<Double> override fun iterator(): MutableIterator<Double> = this@asList.iterator() as MutableIterator<Double>
override fun get(index: Int): Double = this@asList[index] override fun get(index: Int): Double = this@asList[index]
...@@ -10239,7 +10239,7 @@ public fun DoubleArray.asList(): List<Double> { ...@@ -10239,7 +10239,7 @@ public fun DoubleArray.asList(): List<Double> {
public fun FloatArray.asList(): List<Float> { public fun FloatArray.asList(): List<Float> {
return object : AbstractList<Float>(), RandomAccess { return object : AbstractList<Float>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Float): Boolean = this@asList.contains(o) override fun contains(o: Float): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Float> = this@asList.iterator() as MutableIterator<Float> override fun iterator(): MutableIterator<Float> = this@asList.iterator() as MutableIterator<Float>
override fun get(index: Int): Float = this@asList[index] override fun get(index: Int): Float = this@asList[index]
...@@ -10255,7 +10255,7 @@ public fun FloatArray.asList(): List<Float> { ...@@ -10255,7 +10255,7 @@ public fun FloatArray.asList(): List<Float> {
public fun IntArray.asList(): List<Int> { public fun IntArray.asList(): List<Int> {
return object : AbstractList<Int>(), RandomAccess { return object : AbstractList<Int>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Int): Boolean = this@asList.contains(o) override fun contains(o: Int): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Int> = this@asList.iterator() as MutableIterator<Int> override fun iterator(): MutableIterator<Int> = this@asList.iterator() as MutableIterator<Int>
override fun get(index: Int): Int = this@asList[index] override fun get(index: Int): Int = this@asList[index]
...@@ -10271,7 +10271,7 @@ public fun IntArray.asList(): List<Int> { ...@@ -10271,7 +10271,7 @@ public fun IntArray.asList(): List<Int> {
public fun LongArray.asList(): List<Long> { public fun LongArray.asList(): List<Long> {
return object : AbstractList<Long>(), RandomAccess { return object : AbstractList<Long>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Long): Boolean = this@asList.contains(o) override fun contains(o: Long): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Long> = this@asList.iterator() as MutableIterator<Long> override fun iterator(): MutableIterator<Long> = this@asList.iterator() as MutableIterator<Long>
override fun get(index: Int): Long = this@asList[index] override fun get(index: Int): Long = this@asList[index]
...@@ -10287,7 +10287,7 @@ public fun LongArray.asList(): List<Long> { ...@@ -10287,7 +10287,7 @@ public fun LongArray.asList(): List<Long> {
public fun ShortArray.asList(): List<Short> { public fun ShortArray.asList(): List<Short> {
return object : AbstractList<Short>(), RandomAccess { return object : AbstractList<Short>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: Short): Boolean = this@asList.contains(o) override fun contains(o: Short): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<Short> = this@asList.iterator() as MutableIterator<Short> override fun iterator(): MutableIterator<Short> = this@asList.iterator() as MutableIterator<Short>
override fun get(index: Int): Short = this@asList[index] override fun get(index: Int): Short = this@asList[index]
......
...@@ -21,7 +21,7 @@ internal object EmptyList : List<Nothing>, Serializable { ...@@ -21,7 +21,7 @@ internal object EmptyList : List<Nothing>, Serializable {
override fun toString(): String = "[]" override fun toString(): String = "[]"
override val size: Int get() = 0 override val size: Int get() = 0
override fun isEmpty(): Boolean = true override val isEmpty: Boolean get() = true
override fun contains(o: Nothing): Boolean = false override fun contains(o: Nothing): Boolean = false
override fun containsAll(c: Collection<Nothing>): Boolean = c.isEmpty() override fun containsAll(c: Collection<Nothing>): Boolean = c.isEmpty()
......
...@@ -65,7 +65,7 @@ private class MapWithDefaultImpl<K, out V>(public override val map: Map<K,V>, pr ...@@ -65,7 +65,7 @@ private class MapWithDefaultImpl<K, out V>(public override val map: Map<K,V>, pr
override fun hashCode(): Int = map.hashCode() override fun hashCode(): Int = map.hashCode()
override fun toString(): String = map.toString() override fun toString(): String = map.toString()
override val size: Int get() = map.size() override val size: Int get() = map.size()
override fun isEmpty(): Boolean = map.isEmpty() override val isEmpty: Boolean get() = map.isEmpty()
override fun containsKey(key: Any?): Boolean = map.containsKey(key) override fun containsKey(key: Any?): Boolean = map.containsKey(key)
override fun containsValue(value: Any?): Boolean = map.containsValue(value) override fun containsValue(value: Any?): Boolean = map.containsValue(value)
override fun get(key: Any?): V? = map.get(key) override fun get(key: Any?): V? = map.get(key)
...@@ -81,7 +81,7 @@ private class MutableMapWithDefaultImpl<K, V>(public override val map: MutableMa ...@@ -81,7 +81,7 @@ private class MutableMapWithDefaultImpl<K, V>(public override val map: MutableMa
override fun hashCode(): Int = map.hashCode() override fun hashCode(): Int = map.hashCode()
override fun toString(): String = map.toString() override fun toString(): String = map.toString()
override val size: Int get() = map.size() override val size: Int get() = map.size()
override fun isEmpty(): Boolean = map.isEmpty() override val isEmpty: Boolean get() = map.isEmpty()
override fun containsKey(key: Any?): Boolean = map.containsKey(key) override fun containsKey(key: Any?): Boolean = map.containsKey(key)
override fun containsValue(value: Any?): Boolean = map.containsValue(value) override fun containsValue(value: Any?): Boolean = map.containsValue(value)
override fun get(key: Any?): V? = map.get(key) override fun get(key: Any?): V? = map.get(key)
......
...@@ -12,7 +12,7 @@ private object EmptyMap : Map<Any, Nothing>, Serializable { ...@@ -12,7 +12,7 @@ private object EmptyMap : Map<Any, Nothing>, Serializable {
override fun toString(): String = "{}" override fun toString(): String = "{}"
override val size: Int get() = 0 override val size: Int get() = 0
override fun isEmpty(): Boolean = true override val isEmpty: Boolean get() = true
override fun containsKey(key: Any?): Boolean = false override fun containsKey(key: Any?): Boolean = false
override fun containsValue(value: Any?): Boolean = false override fun containsValue(value: Any?): Boolean = false
...@@ -103,18 +103,6 @@ public fun <K,V> Map<K,V>?.orEmpty() : Map<K,V> = this ?: emptyMap() ...@@ -103,18 +103,6 @@ public fun <K,V> Map<K,V>?.orEmpty() : Map<K,V> = this ?: emptyMap()
*/ */
public operator fun <K,V> Map<K,V>.contains(key : K) : Boolean = containsKey(key) public operator fun <K,V> Map<K,V>.contains(key : K) : Boolean = containsKey(key)
/**
* Allows to access the key of a map entry as a property. Equivalent to `getKey()`.
*/
public val <K, V> Map.Entry<K, V>.key: K
get() = getKey()
/**
* Allows to access the value of a map entry as a property. Equivalent to `getValue()`.
*/
public val <K, V> Map.Entry<K, V>.value: V
get() = getValue()
/** /**
* Returns the key component of the map entry. * Returns the key component of the map entry.
* *
......
...@@ -5,9 +5,23 @@ package kotlin ...@@ -5,9 +5,23 @@ package kotlin
@Deprecated("Use property `size` instead", ReplaceWith("this.size")) @Deprecated("Use property `size` instead", ReplaceWith("this.size"))
public inline fun Collection<*>.size() = size public inline fun Collection<*>.size() = size
@Deprecated("Use property `size` instead", ReplaceWith("this.size")) @Deprecated("Use property `size` instead", ReplaceWith("this.size"))
public inline fun Map<*, *>.size() = size public inline fun Map<*, *>.size() = size
@Deprecated("Use property `isEmpty` instead", ReplaceWith("this.isEmpty"))
public inline fun Collection<*>.isEmpty() = isEmpty
@Deprecated("Use property `isEmpty` instead", ReplaceWith("this.isEmpty"))
public inline fun Map<*, *>.isEmpty() = isEmpty
@Deprecated("Use property `key` instead", ReplaceWith("this.key"))
public fun <K, V> Map.Entry<K, V>.getKey(): K = key
@Deprecated("Use property `value` instead", ReplaceWith("this.value"))
public fun <K, V> Map.Entry<K, V>.getValue(): V = value
/** /**
* Adds the specified [element] to this mutable collection. * Adds the specified [element] to this mutable collection.
*/ */
......
...@@ -13,7 +13,7 @@ internal object EmptySet : Set<Nothing>, Serializable { ...@@ -13,7 +13,7 @@ internal object EmptySet : Set<Nothing>, Serializable {
override fun toString(): String = "[]" override fun toString(): String = "[]"
override val size: Int get() = 0 override val size: Int get() = 0
override fun isEmpty(): Boolean = true override val isEmpty: Boolean get() = true
override fun contains(o: Nothing): Boolean = false override fun contains(o: Nothing): Boolean = false
override fun containsAll(c: Collection<Nothing>): Boolean = c.isEmpty() override fun containsAll(c: Collection<Nothing>): Boolean = c.isEmpty()
......
...@@ -221,7 +221,7 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input ...@@ -221,7 +221,7 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input
override val groups: MatchGroupCollection = object : MatchGroupCollection { override val groups: MatchGroupCollection = object : MatchGroupCollection {
override val size: Int get() = matchResult.groupCount() + 1 override val size: Int get() = matchResult.groupCount() + 1
override fun isEmpty(): Boolean = false override val isEmpty: Boolean get() = false
override fun contains(o: MatchGroup?): Boolean = this.any({ it == o }) override fun contains(o: MatchGroup?): Boolean = this.any({ it == o })
override fun containsAll(c: Collection<MatchGroup?>): Boolean = c.all({contains(it)}) override fun containsAll(c: Collection<MatchGroup?>): Boolean = c.all({contains(it)})
......
...@@ -229,7 +229,7 @@ fun specialJVM(): List<GenericFunction> { ...@@ -229,7 +229,7 @@ fun specialJVM(): List<GenericFunction> {
""" """
return object : AbstractList<T>(), RandomAccess { return object : AbstractList<T>(), RandomAccess {
override val size: Int get() = this@asList.size() override val size: Int get() = this@asList.size()
override fun isEmpty(): Boolean = this@asList.isEmpty() override val isEmpty: Boolean get() = this@asList.isEmpty()
override fun contains(o: T): Boolean = this@asList.contains(o) override fun contains(o: T): Boolean = this@asList.contains(o)
override fun iterator(): MutableIterator<T> = this@asList.iterator() as MutableIterator<T> override fun iterator(): MutableIterator<T> = this@asList.iterator() as MutableIterator<T>
override fun get(index: Int): T = this@asList[index] override fun get(index: Int): T = this@asList[index]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册