diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt index 90b79cd8c41..79523493918 100644 --- a/js/js.libraries/src/core/javautil.kt +++ b/js/js.libraries/src/core/javautil.kt @@ -13,7 +13,7 @@ public interface Comparator { @library public abstract class AbstractCollection() : MutableCollection { - override fun isEmpty(): Boolean = noImpl + override val isEmpty: Boolean get() = noImpl override fun contains(o: E): Boolean = noImpl override fun iterator(): MutableIterator = noImpl @@ -103,7 +103,7 @@ public open class LinkedHashSet( @library public open class HashMap(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap { override val size: Int get() = noImpl - override fun isEmpty(): Boolean = noImpl + override val isEmpty: Boolean get() = noImpl @Suppress("BASE_WITH_NULLABLE_UPPER_BOUND") override fun get(key: Any?): V? = noImpl override fun containsKey(key: Any?): Boolean = noImpl diff --git a/js/js.libraries/src/core/regex.kt b/js/js.libraries/src/core/regex.kt index 264ecb11d8b..2574ec82f26 100644 --- a/js/js.libraries/src/core/regex.kt +++ b/js/js.libraries/src/core/regex.kt @@ -178,7 +178,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? { override val groups: MatchGroupCollection = object : MatchGroupCollection { 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 containsAll(c: Collection): Boolean = c.all({contains(it)}) diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 781bf373e1c..323446312fc 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -10175,7 +10175,7 @@ public fun Array.asList(): List { public fun BooleanArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Boolean = this@asList[index] @@ -10191,7 +10191,7 @@ public fun BooleanArray.asList(): List { public fun ByteArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Byte = this@asList[index] @@ -10207,7 +10207,7 @@ public fun ByteArray.asList(): List { public fun CharArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Char = this@asList[index] @@ -10223,7 +10223,7 @@ public fun CharArray.asList(): List { public fun DoubleArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Double = this@asList[index] @@ -10239,7 +10239,7 @@ public fun DoubleArray.asList(): List { public fun FloatArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Float = this@asList[index] @@ -10255,7 +10255,7 @@ public fun FloatArray.asList(): List { public fun IntArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Int = this@asList[index] @@ -10271,7 +10271,7 @@ public fun IntArray.asList(): List { public fun LongArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Long = this@asList[index] @@ -10287,7 +10287,7 @@ public fun LongArray.asList(): List { public fun ShortArray.asList(): List { return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): Short = this@asList[index] diff --git a/libraries/stdlib/src/kotlin/collections/JUtil.kt b/libraries/stdlib/src/kotlin/collections/JUtil.kt index 555e1f41560..1c9ad52b640 100644 --- a/libraries/stdlib/src/kotlin/collections/JUtil.kt +++ b/libraries/stdlib/src/kotlin/collections/JUtil.kt @@ -21,7 +21,7 @@ internal object EmptyList : List, Serializable { override fun toString(): String = "[]" 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 containsAll(c: Collection): Boolean = c.isEmpty() diff --git a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt index 09aaea4235a..32bc496c047 100644 --- a/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt +++ b/libraries/stdlib/src/kotlin/collections/MapWithDefault.kt @@ -65,7 +65,7 @@ private class MapWithDefaultImpl(public override val map: Map, pr override fun hashCode(): Int = map.hashCode() override fun toString(): String = map.toString() 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 containsValue(value: Any?): Boolean = map.containsValue(value) override fun get(key: Any?): V? = map.get(key) @@ -81,7 +81,7 @@ private class MutableMapWithDefaultImpl(public override val map: MutableMa override fun hashCode(): Int = map.hashCode() override fun toString(): String = map.toString() 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 containsValue(value: Any?): Boolean = map.containsValue(value) override fun get(key: Any?): V? = map.get(key) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index db067f39fec..0872343a40c 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -12,7 +12,7 @@ private object EmptyMap : Map, Serializable { override fun toString(): String = "{}" 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 containsValue(value: Any?): Boolean = false @@ -103,18 +103,6 @@ public fun Map?.orEmpty() : Map = this ?: emptyMap() */ public operator fun Map.contains(key : K) : Boolean = containsKey(key) -/** - * Allows to access the key of a map entry as a property. Equivalent to `getKey()`. - */ -public val Map.Entry.key: K - get() = getKey() - -/** - * Allows to access the value of a map entry as a property. Equivalent to `getValue()`. - */ -public val Map.Entry.value: V - get() = getValue() - /** * Returns the key component of the map entry. * diff --git a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt index f2e50db6c87..d739a2221ce 100644 --- a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt +++ b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt @@ -5,9 +5,23 @@ package kotlin @Deprecated("Use property `size` instead", ReplaceWith("this.size")) public inline fun Collection<*>.size() = size + @Deprecated("Use property `size` instead", ReplaceWith("this.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 Map.Entry.getKey(): K = key + +@Deprecated("Use property `value` instead", ReplaceWith("this.value")) +public fun Map.Entry.getValue(): V = value + /** * Adds the specified [element] to this mutable collection. */ diff --git a/libraries/stdlib/src/kotlin/collections/Sets.kt b/libraries/stdlib/src/kotlin/collections/Sets.kt index 2e5c5c24dc8..c0e4af898fc 100644 --- a/libraries/stdlib/src/kotlin/collections/Sets.kt +++ b/libraries/stdlib/src/kotlin/collections/Sets.kt @@ -13,7 +13,7 @@ internal object EmptySet : Set, Serializable { override fun toString(): String = "[]" 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 containsAll(c: Collection): Boolean = c.isEmpty() diff --git a/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt b/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt index 4f6d31c6e85..99f8cd3645a 100644 --- a/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt +++ b/libraries/stdlib/src/kotlin/text/regex/RegexJVM.kt @@ -221,7 +221,7 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input override val groups: MatchGroupCollection = object : MatchGroupCollection { 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 containsAll(c: Collection): Boolean = c.all({contains(it)}) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt index efc18322432..ef9e8b96df0 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/SpecialJVM.kt @@ -229,7 +229,7 @@ fun specialJVM(): List { """ return object : AbstractList(), RandomAccess { 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 iterator(): MutableIterator = this@asList.iterator() as MutableIterator override fun get(index: Int): T = this@asList[index]