From 9088bf67c708a2714e9a52098401cc9a283d9ab5 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 13 Oct 2015 20:33:59 +0300 Subject: [PATCH] Extract and clean deprecated builtin extensions --- .../kotlin/collections/DeprecatedBuiltins.kt | 80 +++++++++++++++++++ .../kotlin/collections/MutableCollections.kt | 62 -------------- 2 files changed, 80 insertions(+), 62 deletions(-) create mode 100644 libraries/stdlib/src/kotlin/collections/DeprecatedBuiltins.kt diff --git a/libraries/stdlib/src/kotlin/collections/DeprecatedBuiltins.kt b/libraries/stdlib/src/kotlin/collections/DeprecatedBuiltins.kt new file mode 100644 index 00000000000..a000a9823e8 --- /dev/null +++ b/libraries/stdlib/src/kotlin/collections/DeprecatedBuiltins.kt @@ -0,0 +1,80 @@ +/* + * Copyright 2010-2015 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@file:kotlin.jvm.JvmName("DeprecatedBuiltinsKt") + +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 + +@Deprecated("Use operator 'get' instead", ReplaceWith("this[index]")) +public fun CharSequence.charAt(index: Int): Char = this[index] + +@Deprecated("Use 'removeAt' instead", ReplaceWith("this.removeAt(index)")) +public fun MutableList.remove(index: Int): E = removeAt(index) + +@Deprecated("Use explicit cast to MutableCollection instead", ReplaceWith("(this as MutableCollection).remove(o)")) +public fun MutableCollection.remove(o: Any?): Boolean = remove(o as E) + +@Deprecated("Use property 'length' instead", ReplaceWith("this.length")) +public fun CharSequence.length(): Int = length + +@Deprecated("Use explicit cast to Map instead", ReplaceWith("(this as Map).get(o)")) +public inline operator fun Map.get(o: Any?): V? = get(o as K) + +@Deprecated("Use explicit cast to Map instead", ReplaceWith("(this as Map).containsKey(o)")) +public inline fun Map.containsKey(o: Any?): Boolean = containsKey(o as K) + +@Deprecated("Use explicit cast to Map instead", ReplaceWith("(this as Map).containsValue(o)")) +public inline fun Map.containsValue(o: Any?): Boolean = containsValue(o as V) + +@Deprecated("Use property 'keys' instead", ReplaceWith("this.keys")) +public inline fun Map.keySet(): Set = keys + +@kotlin.jvm.JvmName("mutableKeys") +@Deprecated("Use property 'keys' instead", ReplaceWith("this.keys")) +public inline fun MutableMap.keySet(): MutableSet = keys + +@Deprecated("Use property 'entries' instead", ReplaceWith("this.entries")) +public inline fun Map.entrySet(): Set> = entries + +@kotlin.jvm.JvmName("mutableEntrySet") +@Deprecated("Use property 'entries' instead", ReplaceWith("this.entries")) +public inline fun MutableMap.entrySet(): MutableSet> = entries + +@Deprecated("Use property 'values' instead", ReplaceWith("this.values")) +public inline fun Map.values(): Collection = values + +@kotlin.jvm.JvmName("mutableValues") +@Deprecated("Use property 'values' instead", ReplaceWith("this.values")) +public inline fun MutableMap.values(): MutableCollection = values diff --git a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt index ab6349eb5c1..bc48f18b874 100644 --- a/libraries/stdlib/src/kotlin/collections/MutableCollections.kt +++ b/libraries/stdlib/src/kotlin/collections/MutableCollections.kt @@ -3,68 +3,6 @@ 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 - -@Deprecated("Use operator 'get' instead", ReplaceWith("this[index]")) -public fun CharSequence.charAt(index: Int): Char = this[index] - -@Deprecated("Use `removeAt` instead", ReplaceWith("this.removeAt(index)")) -public fun MutableList.remove(index: Int): E = removeAt(index) - -@Deprecated("Use explicit cast to MutableCollection instead", ReplaceWith("(this as MutableCollection).remove(o)")) -public fun MutableCollection.remove(o: Any?): Boolean = remove(o as E) - -@Deprecated("Use 'length' property instead", ReplaceWith("this.length")) -public fun CharSequence.length(): Int = length - -@Deprecated("Use explicit cast to Map instead", ReplaceWith("(this as Map).get(o)")) -public inline operator fun Map.get(o: Any?): V? = get(o as K) - -@Deprecated("Use explicit cast to Map instead", ReplaceWith("(this as Map).containsKey(o)")) -public inline fun Map.containsKey(o: Any?): Boolean = containsKey(o as K) - -@Deprecated("Use explicit cast to Map instead", ReplaceWith("(this as Map).containsValue(o)")) -public inline fun Map.containsValue(o: Any?): Boolean = containsValue(o as V) - -@Deprecated("Use 'keys' instead", ReplaceWith("this.keys()")) -public inline fun Map.keySet(): Set = keys - -@kotlin.jvm.JvmName("mutableKeys") -@Deprecated("Use 'keys' instead", ReplaceWith("this.keys")) -public inline fun MutableMap.keySet(): MutableSet = keys - -@Deprecated("Use 'entries' instead", ReplaceWith("this.entries")) -public inline fun Map.entrySet(): Set> = entries - -@kotlin.jvm.JvmName("mutableEntrySet") -@Deprecated("Use 'entries' instead", ReplaceWith("this.entries")) -public inline fun MutableMap.entrySet(): MutableSet> = entries - -@Deprecated("Use 'values' properties instead", ReplaceWith("this.values")) -public inline fun Map.values(): Collection = values - -@kotlin.jvm.JvmName("mutableValues") -@Deprecated("Use 'values' properties instead", ReplaceWith("this.values")) -public inline fun MutableMap.values(): MutableCollection = values - - /** * Adds the specified [element] to this mutable collection. */