From b4ebaad8f5029a1431ff2e0125a04f3e5c0f5131 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 5 Feb 2016 16:14:16 +0300 Subject: [PATCH] Drop previously deprecated API. --- .../SubstitutedSignature3.kt | 2 +- .../java/ExtensionFromStandardLibrary.kt | 5 +- .../basic/java/TopLevelFromStandardLibrary.kt | 4 +- .../DecompiledTextConsistencyTest.kt | 2 +- .../kotlin/test/TestAssertionsJVM.kt | 9 - libraries/stdlib/src/generated/_Arrays.kt | 313 ----------------- .../stdlib/src/generated/_Collections.kt | 43 --- libraries/stdlib/src/generated/_Sequences.kt | 33 -- libraries/stdlib/src/generated/_Strings.kt | 33 -- .../src/kotlin/collections/ArraysJVM.kt | 5 - .../src/kotlin/collections/Collections.kt | 10 - .../stdlib/src/kotlin/collections/Maps.kt | 66 ---- .../stdlib/src/kotlin/collections/MapsJVM.kt | 6 - .../src/kotlin/collections/Sequences.kt | 10 - .../stdlib/src/kotlin/concurrent/Thread.kt | 7 - libraries/stdlib/src/kotlin/io/Constants.kt | 3 - .../stdlib/src/kotlin/io/FileReadWrite.kt | 55 --- libraries/stdlib/src/kotlin/io/IOStreams.kt | 16 - libraries/stdlib/src/kotlin/io/ReadWrite.kt | 11 - libraries/stdlib/src/kotlin/io/files/Utils.kt | 4 - libraries/stdlib/src/kotlin/system/Timing.kt | 6 - .../stdlib/src/kotlin/text/StringsJVM.kt | 58 --- .../src/kotlin/util/OrderingDeprecated.kt | 330 ------------------ .../src/templates/Snapshots.kt | 66 ---- 24 files changed, 7 insertions(+), 1090 deletions(-) delete mode 100644 libraries/stdlib/src/kotlin/util/OrderingDeprecated.kt diff --git a/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature3.kt b/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature3.kt index 3fa3974ee38..50dbb5ec939 100644 --- a/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature3.kt +++ b/idea/idea-completion/testData/basic/common/substitutedSignature/SubstitutedSignature3.kt @@ -2,4 +2,4 @@ fun foo(list: List) { list. } // EXIST: { itemText: "firstOrNull", tailText: " {...} (predicate: (String) -> Boolean) for Iterable in kotlin.collections", typeText: "String?" } -// EXIST: { itemText: "toMapBy", tailText: " {...} (selector: (String) -> K) for Iterable in kotlin.collections", typeText: "Map" } +// EXIST: { itemText: "associateBy", tailText: " {...} (keySelector: (String) -> K) for Iterable in kotlin.collections", typeText: "Map" } diff --git a/idea/idea-completion/testData/basic/java/ExtensionFromStandardLibrary.kt b/idea/idea-completion/testData/basic/java/ExtensionFromStandardLibrary.kt index 7893e5b1877..b03a4ce51c2 100644 --- a/idea/idea-completion/testData/basic/java/ExtensionFromStandardLibrary.kt +++ b/idea/idea-completion/testData/basic/java/ExtensionFromStandardLibrary.kt @@ -4,9 +4,10 @@ import java.util.HashMap fun firstFun() { val a = HashMap() - a.toLinke + a.toSort } // INVOCATION_COUNT: 1 -// EXIST: { lookupString:"toLinkedMap", itemText:"toLinkedMap", tailText:"() for Map in kotlin.collections" } +// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"() for Map in kotlin.collections" } +// EXIST: { lookupString:"toSortedMap", itemText:"toSortedMap", tailText:"(comparator: Comparator) for Map in kotlin.collections" } // NOTHING_ELSE diff --git a/idea/idea-completion/testData/basic/java/TopLevelFromStandardLibrary.kt b/idea/idea-completion/testData/basic/java/TopLevelFromStandardLibrary.kt index 8c00b0e6d85..b8ef7c9bf78 100644 --- a/idea/idea-completion/testData/basic/java/TopLevelFromStandardLibrary.kt +++ b/idea/idea-completion/testData/basic/java/TopLevelFromStandardLibrary.kt @@ -1,10 +1,10 @@ package testing fun someFun() { - measureTime + measure } // Important: This test checks that completion will find top level functions from jars. // If you going to update it make sure that methods are not auto-imported -// EXIST: measureTimeNano, measureTimeMillis \ No newline at end of file +// EXIST: measureNanoTime, measureTimeMillis \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt index ddfd45cb632..07e29b407ae 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/decompiler/textBuilder/DecompiledTextConsistencyTest.kt @@ -40,7 +40,7 @@ class DecompiledTextConsistencyTest : TextConsistencyBaseTest() { override fun getFacades(): List = listOf(FqName("kotlin.collections.CollectionsKt")) - override fun getTopLevelMembers(): Map = mapOf("kotlin.collections.CollectionsKt" to "linkedListOf") + override fun getTopLevelMembers(): Map = mapOf("kotlin.collections.CollectionsKt" to "mutableListOf") override fun getVirtualFileFinder(): VirtualFileFinder = JvmVirtualFileFinder.SERVICE.getInstance(project) diff --git a/libraries/kotlin.test/shared/src/main/kotlin.jvm/kotlin/test/TestAssertionsJVM.kt b/libraries/kotlin.test/shared/src/main/kotlin.jvm/kotlin/test/TestAssertionsJVM.kt index 5f714fed984..a32363bd17e 100644 --- a/libraries/kotlin.test/shared/src/main/kotlin.jvm/kotlin/test/TestAssertionsJVM.kt +++ b/libraries/kotlin.test/shared/src/main/kotlin.jvm/kotlin/test/TestAssertionsJVM.kt @@ -4,15 +4,6 @@ package kotlin.test import kotlin.reflect.* -/** Asserts that a [block] fails with a specific exception being thrown. */ -@Deprecated("Use assertFailsWith with kotlin class.", ReplaceWith("assertFailsWith(exceptionClass.kotlin, block)"), level = DeprecationLevel.ERROR) -fun assertFailsWith(exceptionClass: Class, block: () -> Unit): T { - return assertFailsWithImpl(exceptionClass, null, block) -} - -@Deprecated("Use assertFailsWith with kotlin class.", ReplaceWith("assertFailsWith(exceptionClass.kotlin, message, block)"), level = DeprecationLevel.ERROR) -fun assertFailsWith(exceptionClass: Class, message: String?, block: () -> Unit): T = assertFailsWithImpl(exceptionClass, message, block) - /** Asserts that a [block] fails with a specific exception being thrown. */ private fun assertFailsWithImpl(exceptionClass: Class, message: String?, block: () -> Unit): T { try { diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 6a11663e0d0..85bed38ae7d 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -6115,94 +6115,6 @@ public inline fun > CharArray.associateTo(desti return destination } -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun Array.toArrayList(): ArrayList { - return ArrayList(this.asCollection()) -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun ByteArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun ShortArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun IntArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun LongArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun FloatArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun DoubleArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun BooleanArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun CharArray.toArrayList(): ArrayList { - val list = ArrayList(size) - for (item in this) list.add(item) - return list -} - /** * Appends all elements to the given [destination] collection. */ @@ -6419,231 +6331,6 @@ public fun CharArray.toList(): List { return this.toMutableList() } -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun Array.toMap(selector: (T) -> K, transform: (T) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun ByteArray.toMap(selector: (Byte) -> K, transform: (Byte) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun ShortArray.toMap(selector: (Short) -> K, transform: (Short) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun IntArray.toMap(selector: (Int) -> K, transform: (Int) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun LongArray.toMap(selector: (Long) -> K, transform: (Long) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun FloatArray.toMap(selector: (Float) -> K, transform: (Float) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun DoubleArray.toMap(selector: (Double) -> K, transform: (Double) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun BooleanArray.toMap(selector: (Boolean) -> K, transform: (Boolean) -> V): Map { - return associateBy(selector, transform) -} - -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given array. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun CharArray.toMap(selector: (Char) -> K, transform: (Char) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun Array.toMap(transform: (T) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun ByteArray.toMap(transform: (Byte) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun ShortArray.toMap(transform: (Short) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun IntArray.toMap(transform: (Int) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun LongArray.toMap(transform: (Long) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun FloatArray.toMap(transform: (Float) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun DoubleArray.toMap(transform: (Double) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun BooleanArray.toMap(transform: (Boolean) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun CharArray.toMap(transform: (Char) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun Array.toMapBy(selector: (T) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun ByteArray.toMapBy(selector: (Byte) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun ShortArray.toMapBy(selector: (Short) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun IntArray.toMapBy(selector: (Int) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun LongArray.toMapBy(selector: (Long) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun FloatArray.toMapBy(selector: (Float) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun DoubleArray.toMapBy(selector: (Double) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun BooleanArray.toMapBy(selector: (Boolean) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun CharArray.toMapBy(selector: (Char) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun Array.toMapBy(selector: (T) -> K, transform: (T) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun ByteArray.toMapBy(selector: (Byte) -> K, transform: (Byte) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun ShortArray.toMapBy(selector: (Short) -> K, transform: (Short) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun IntArray.toMapBy(selector: (Int) -> K, transform: (Int) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun LongArray.toMapBy(selector: (Long) -> K, transform: (Long) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun FloatArray.toMapBy(selector: (Float) -> K, transform: (Float) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun DoubleArray.toMapBy(selector: (Double) -> K, transform: (Double) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun BooleanArray.toMapBy(selector: (Boolean) -> K, transform: (Boolean) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun CharArray.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map { - return associateBy(selector, transform) -} - /** * Returns a [MutableList] filled with all elements of this array. */ diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 12657e7f0b9..ebff7bd21f4 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -990,24 +990,6 @@ public inline fun > Iterable.associateTo( return destination } -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun Iterable.toArrayList(): ArrayList { - if (this is Collection) - return ArrayList(this) - return toCollection(ArrayList()) -} - -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun Collection.toArrayList(): ArrayList { - return ArrayList(this) -} - /** * Appends all elements to the given [destination] collection. */ @@ -1032,31 +1014,6 @@ public fun Iterable.toList(): List { return this.toMutableList() } -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given collection. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun Iterable.toMap(selector: (T) -> K, transform: (T) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun Iterable.toMap(transform: (T) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun Iterable.toMapBy(selector: (T) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun Iterable.toMapBy(selector: (T) -> K, transform: (T) -> V): Map { - return associateBy(selector, transform) -} - /** * Returns a [MutableList] filled with all elements of this collection. */ diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 348fad72c13..bb316f3e9ee 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -488,14 +488,6 @@ public inline fun > Sequence.associateTo( return destination } -/** - * Returns an [ArrayList] of all elements. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun Sequence.toArrayList(): ArrayList { - return toCollection(ArrayList()) -} - /** * Appends all elements to the given [destination] collection. */ @@ -520,31 +512,6 @@ public fun Sequence.toList(): List { return this.toMutableList() } -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to elements of the given sequence. - * If any two elements would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun Sequence.toMap(selector: (T) -> K, transform: (T) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun Sequence.toMap(transform: (T) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun Sequence.toMapBy(selector: (T) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun Sequence.toMapBy(selector: (T) -> K, transform: (T) -> V): Map { - return associateBy(selector, transform) -} - /** * Returns a [MutableList] filled with all elements of this sequence. */ diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index a8a7bbdc91f..92080c148d1 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -563,14 +563,6 @@ public inline fun > CharSequence.associateTo(de return destination } -/** - * Returns an [ArrayList] of all characters. - */ -@Deprecated("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", ReplaceWith("toCollection(arrayListOf())"), level = DeprecationLevel.ERROR) -public fun CharSequence.toArrayList(): ArrayList { - return toCollection(ArrayList(length)) -} - /** * Appends all characters to the given [destination] collection. */ @@ -595,31 +587,6 @@ public fun CharSequence.toList(): List { return this.toMutableList() } -/** - * Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to characters of the given char sequence. - * If any two characters would have the same key returned by [selector] the last one gets added to the map. - */ -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun CharSequence.toMap(selector: (Char) -> K, transform: (Char) -> V): Map { - return associateBy(selector, transform) -} - -@Deprecated("Use associate instead.", ReplaceWith("associate(transform)"), level = DeprecationLevel.ERROR) -@kotlin.jvm.JvmName("toMapOfPairs") -public inline fun CharSequence.toMap(transform: (Char) -> Pair): Map { - return associate(transform) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector)"), level = DeprecationLevel.ERROR) -public inline fun CharSequence.toMapBy(selector: (Char) -> K): Map { - return associateBy(selector) -} - -@Deprecated("Use associateBy instead.", ReplaceWith("associateBy(selector, transform)"), level = DeprecationLevel.ERROR) -public inline fun CharSequence.toMapBy(selector: (Char) -> K, transform: (Char) -> V): Map { - return associateBy(selector, transform) -} - /** * Returns a [MutableList] filled with all characters of this char sequence. */ diff --git a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt index a48d06be03b..a1823894dff 100644 --- a/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/ArraysJVM.kt @@ -5,11 +5,6 @@ package kotlin.collections import java.nio.charset.Charset -/** - * Converts the contents of this byte array to a string using the specified [charset]. - */ -@Deprecated("Use ByteArray.toString(Charset) instead.", ReplaceWith("this.toString(charset(charset))"), level = DeprecationLevel.ERROR) -public fun ByteArray.toString(charset: String): String = String(this, charset(charset)) /** * Converts the contents of this byte array to a string using the specified [charset]. diff --git a/libraries/stdlib/src/kotlin/collections/Collections.kt b/libraries/stdlib/src/kotlin/collections/Collections.kt index fa69a5ad20e..49f3cde95c7 100644 --- a/libraries/stdlib/src/kotlin/collections/Collections.kt +++ b/libraries/stdlib/src/kotlin/collections/Collections.kt @@ -74,16 +74,6 @@ public inline fun listOf(): List = emptyList() @JvmVersion public fun listOf(element: T): List = Collections.singletonList(element) -/** Returns a new [LinkedList] with the given elements. */ -@JvmVersion -@Deprecated("Use LinkedList constructor.", ReplaceWith("LinkedList(listOf(*elements))", "java.util.LinkedList"), level = DeprecationLevel.ERROR) -public fun linkedListOf(vararg elements: T): LinkedList - = if (elements.size == 0) LinkedList() else LinkedList(ArrayAsCollection(elements)) - -@Deprecated("Use LinkedList constructor.", ReplaceWith("LinkedList()", "java.util.LinkedList"), level = DeprecationLevel.ERROR) -public fun linkedListOf() = LinkedList() - - /** Returns a new [MutableList] with the given elements. */ public fun mutableListOf(vararg elements: T): MutableList = if (elements.size == 0) ArrayList() else ArrayList(ArrayAsCollection(elements)) diff --git a/libraries/stdlib/src/kotlin/collections/Maps.kt b/libraries/stdlib/src/kotlin/collections/Maps.kt index f2c6a338b52..e68546a6e7b 100644 --- a/libraries/stdlib/src/kotlin/collections/Maps.kt +++ b/libraries/stdlib/src/kotlin/collections/Maps.kt @@ -398,12 +398,6 @@ public fun Sequence>.toMap(): Map = toMap(LinkedHashMap< public fun > Sequence>.toMap(destination: M): M = destination.apply { putAll(this@toMap) } -/** - * Converts this [Map] to a [LinkedHashMap], maintaining the insertion order of elements added to that map afterwards. - */ -@Deprecated("It may be too late to convert map this map to linked map, if you care about the order use the ordered map from the beginning.", ReplaceWith("LinkedHashMap(this)", "java.util.LinkedHashMap"), level = DeprecationLevel.ERROR) -public fun Map.toLinkedMap(): MutableMap = LinkedHashMap(this) - /** * Creates a new read-only map by replacing or adding an entry to this map from a given key-value [pair]. */ @@ -474,63 +468,3 @@ public inline operator fun MutableMap.plusAssign(pairs: Seque public inline operator fun MutableMap.plusAssign(map: Map) { putAll(map) } - -/** - * Creates a new read-only map by removing a [key] from this map. - */ -@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= key.", level = DeprecationLevel.ERROR) -public operator fun Map.minus(key: K): Map - = LinkedHashMap(this).apply { keys.remove(key) } - -/** - * Creates a new read-only map by removing a collection of [keys] from this map. - */ -@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= keys.", level = DeprecationLevel.ERROR) -public operator fun Map.minus(keys: Iterable): Map - = LinkedHashMap(this).apply { for (key in keys) remove(key) } - -/** - * Creates a new read-only map by removing a array of [keys] from this map. - */ -@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= keys.", level = DeprecationLevel.ERROR) -public operator fun Map.minus(keys: Array): Map - = LinkedHashMap(this).apply { for (key in keys) remove(key) } - -/** - * Creates a new read-only map by removing a sequence of [keys] from this map. - */ -@Deprecated("This operation is going to be removed. Copy this map to mutable map and then do result.keys -= keys.", level = DeprecationLevel.ERROR) -public operator fun Map.minus(keys: Sequence): Map - = LinkedHashMap(this).apply { for (key in keys) remove(key) } - -/** - * Removes the given [key] from this mutable map. - */ -@Deprecated("This operation will be removed soon, use remove(key) instead.", ReplaceWith("this.keys -= key"), level = DeprecationLevel.ERROR) -public operator fun MutableMap.minusAssign(key: K) { - remove(key) -} - -/** - * Removes all the given [keys] from this mutable map. - */ -@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"), level = DeprecationLevel.ERROR) -public operator fun MutableMap.minusAssign(keys: Iterable) { - for (key in keys) remove(key) -} - -/** - * Removes all the given [keys] from this mutable map. - */ -@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"), level = DeprecationLevel.ERROR) -public operator fun MutableMap.minusAssign(keys: Array) { - for (key in keys) remove(key) -} - -/** - * Removes all the given [keys] from this mutable map. - */ -@Deprecated("This operation will be removed soon.", ReplaceWith("this.keys -= keys"), level = DeprecationLevel.ERROR) -public operator fun MutableMap.minusAssign(keys: Sequence) { - for (key in keys) remove(key) -} diff --git a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt index e730cf7547d..52d7e79d1a7 100644 --- a/libraries/stdlib/src/kotlin/collections/MapsJVM.kt +++ b/libraries/stdlib/src/kotlin/collections/MapsJVM.kt @@ -35,12 +35,6 @@ public inline fun ConcurrentMap.getOrPut(key: K, defaultValue: () - } -@Deprecated("Use getOrPut instead", ReplaceWith("getOrPut(key, defaultValue)"), level = DeprecationLevel.ERROR) -public inline fun ConcurrentMap.concurrentGetOrPut(key: K, defaultValue: () -> V): V { - // Do not use computeIfAbsent on JVM8 as it would change locking behavior - return this.get(key) ?: - defaultValue().let { default -> this.putIfAbsent(key, default) ?: default } -} /** * Converts this [Map] to a [SortedMap] so iteration order will be in key order. diff --git a/libraries/stdlib/src/kotlin/collections/Sequences.kt b/libraries/stdlib/src/kotlin/collections/Sequences.kt index 6b9306b5ac9..49b7696cb64 100644 --- a/libraries/stdlib/src/kotlin/collections/Sequences.kt +++ b/libraries/stdlib/src/kotlin/collections/Sequences.kt @@ -492,9 +492,6 @@ public fun generateSequence(nextFunction: () -> T?): Sequence { return GeneratorSequence(nextFunction, { nextFunction() }).constrainOnce() } -@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(nextFunction)"), level = DeprecationLevel.ERROR) -public fun sequence(nextFunction: () -> T?): Sequence = generateSequence(nextFunction) - /** * Returns a sequence which invokes the function to calculate the next value based on the previous one on each iteration * until the function returns `null`. The sequence starts with the specified [seed]. @@ -508,10 +505,6 @@ public fun generateSequence(seed: T?, nextFunction: (T) -> T?): Sequen else GeneratorSequence({ seed }, nextFunction) -@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(initialValue, nextFunction)"), level = DeprecationLevel.ERROR) -@kotlin.internal.LowPriorityInOverloadResolution -public fun sequence(initialValue: T?, nextFunction: (T) -> T?): Sequence = generateSequence(initialValue, nextFunction) - /** * Returns a sequence which invokes the function [seedFunction] to get the first item and then * [nextFunction] to calculate the next value based on the previous one on each iteration @@ -520,6 +513,3 @@ public fun sequence(initialValue: T?, nextFunction: (T) -> T?): Sequen public fun generateSequence(seedFunction: () -> T?, nextFunction: (T) -> T?): Sequence = GeneratorSequence(seedFunction, nextFunction) - -@Deprecated("Use generateSequence instead.", ReplaceWith("generateSequence(initialValueFunction, nextFunction)"), level = DeprecationLevel.ERROR) -public fun sequence(initialValueFunction: () -> T?, nextFunction: (T) -> T?): Sequence = generateSequence(initialValueFunction, nextFunction) diff --git a/libraries/stdlib/src/kotlin/concurrent/Thread.kt b/libraries/stdlib/src/kotlin/concurrent/Thread.kt index 2f16e3ead23..b9af462fb4b 100644 --- a/libraries/stdlib/src/kotlin/concurrent/Thread.kt +++ b/libraries/stdlib/src/kotlin/concurrent/Thread.kt @@ -2,13 +2,6 @@ @file:JvmName("ThreadsKt") package kotlin.concurrent -/** - * Returns the current thread. - */ -@Deprecated("Use Thread.currentThread()", ReplaceWith("Thread.currentThread()"), level = DeprecationLevel.ERROR) -public val currentThread: Thread - get() = Thread.currentThread() - /** * Creates a thread that runs the specified [block] of code. * diff --git a/libraries/stdlib/src/kotlin/io/Constants.kt b/libraries/stdlib/src/kotlin/io/Constants.kt index a4c53dd7a0c..0f15a2d58b1 100644 --- a/libraries/stdlib/src/kotlin/io/Constants.kt +++ b/libraries/stdlib/src/kotlin/io/Constants.kt @@ -8,9 +8,6 @@ package kotlin.io public const val DEFAULT_BUFFER_SIZE: Int = 64 * 1024 -@Deprecated("Use DEFAULT_BUFFER_SIZE constant instead.", ReplaceWith("kotlin.io.DEFAULT_BUFFER_SIZE"), level = DeprecationLevel.ERROR) -public val defaultBufferSize: Int = DEFAULT_BUFFER_SIZE - /** * Returns the default block size for forEachBlock(). */ diff --git a/libraries/stdlib/src/kotlin/io/FileReadWrite.kt b/libraries/stdlib/src/kotlin/io/FileReadWrite.kt index 8ffdf44a6b9..1efce324d3c 100644 --- a/libraries/stdlib/src/kotlin/io/FileReadWrite.kt +++ b/libraries/stdlib/src/kotlin/io/FileReadWrite.kt @@ -66,17 +66,6 @@ public fun File.writeBytes(array: ByteArray): Unit = FileOutputStream(this).use */ public fun File.appendBytes(array: ByteArray): Unit = FileOutputStream(this, true).use { it.write(array) } -/** - * Gets the entire content of this file as a String using specified [charset]. - * - * This method is not recommended on huge files. It has an internal limitation of 2 GB file size. - * - * @param charset character set to use. - * @return the entire content of this file as a String. - */ -@Deprecated("Use File.readText(Charset) instead.", ReplaceWith("this.readText(charset(charset))"), level = DeprecationLevel.ERROR) -public fun File.readText(charset: String): String = readBytes().toString(charset(charset)) - /** * Gets the entire content of this file as a String using UTF-8 or specified [charset]. * @@ -87,16 +76,6 @@ public fun File.readText(charset: String): String = readBytes().toString(charset */ public fun File.readText(charset: Charset = Charsets.UTF_8): String = readBytes().toString(charset) -/** - * Sets the content of this file as [text] encoded using the specified [charset]. - * If this file exists, it becomes overwritten. - * - * @param text text to write into file. - * @param charset character set to use. - */ -@Deprecated("Use File.writeText(String, Charset) instead.", ReplaceWith("this.writeText(text, charset(charset))"), level = DeprecationLevel.ERROR) -public fun File.writeText(text: String, charset: String): Unit = writeBytes(text.toByteArray(charset(charset))) - /** * Sets the content of this file as [text] encoded using UTF-8 or specified [charset]. * If this file exists, it becomes overwritten. @@ -114,15 +93,6 @@ public fun File.writeText(text: String, charset: Charset = Charsets.UTF_8): Unit */ public fun File.appendText(text: String, charset: Charset = Charsets.UTF_8): Unit = appendBytes(text.toByteArray(charset)) -/** - * Appends [text] to the content of the file using the specified [charset]. - * - * @param text text to append to file. - * @param charset character set to use. - */ -@Deprecated("Use File.appendText(String, Charset) instead.", ReplaceWith("this.appendText(text, charset(charset))"), level = DeprecationLevel.ERROR) -public fun File.appendText(text: String, charset: String): Unit = appendBytes(text.toByteArray(charset(charset))) - /** * Reads file by byte blocks and calls [action] for each block read. * Block has default size which is implementation-dependent. @@ -134,9 +104,6 @@ public fun File.appendText(text: String, charset: String): Unit = appendBytes(te */ public fun File.forEachBlock(action: (ByteArray, Int) -> Unit): Unit = forEachBlock(defaultBlockSize, action) -@Deprecated("Use forEachBlock with blockSize as a first parameter.", ReplaceWith("forEachBlock(blockSize, action)"), level = DeprecationLevel.ERROR) -public fun File.forEachBlock(action: (ByteArray, Int) -> Unit, blockSize: Int): Unit - = forEachBlock(blockSize, action) /** * Reads file by byte blocks and calls [action] for each block read. * This functions passes the byte array and amount of bytes in the array to the [action] function. @@ -178,28 +145,6 @@ public fun File.forEachLine(charset: Charset = Charsets.UTF_8, action: (line: St BufferedReader(InputStreamReader(FileInputStream(this), charset)).forEachLine(action) } -/** - * Reads this file line by line using the specified [charset] and calls [operation] for each line. - * - * You may use this function on huge files. - * - * @param charset character set to use. - * @param operation function to process file lines. - */ -@Deprecated("Use File.forEachLine(Charset, operation) instead.", ReplaceWith("this.forEachLine(charset(charset), operation)"), level = DeprecationLevel.ERROR) -public fun File.forEachLine(charset: String, operation: (line: String) -> Unit): Unit = forEachLine(Charset.forName(charset), operation) - -/** - * Reads the file content as a list of lines, using the specified [charset]. - * - * Do not use this function for huge files. - * - * @param charset character set to use. - * @return list of file lines. - */ -@Deprecated("Use File.readLines(Charset) instead.", ReplaceWith("this.readLines(charset(charset))"), level = DeprecationLevel.ERROR) -public fun File.readLines(charset: String): List = readLines(Charset.forName(charset)) - /** * Constructs a new FileInputStream of this file and returns it as a result. */ diff --git a/libraries/stdlib/src/kotlin/io/IOStreams.kt b/libraries/stdlib/src/kotlin/io/IOStreams.kt index 225ff805e0d..3976ffa6824 100644 --- a/libraries/stdlib/src/kotlin/io/IOStreams.kt +++ b/libraries/stdlib/src/kotlin/io/IOStreams.kt @@ -74,14 +74,6 @@ public inline fun InputStream.reader(charset: Charset = Charsets.UTF_8): InputSt @kotlin.internal.InlineOnly public inline fun InputStream.bufferedReader(charset: Charset = Charsets.UTF_8): BufferedReader = reader(charset).buffered() -/** Creates a reader on this input stream using the specified [charset]. */ -@Deprecated("Use InputStream.reader(Charset) instead.", ReplaceWith("this.reader(charset(charset))"), level = DeprecationLevel.ERROR) -public fun InputStream.reader(charset: String): InputStreamReader = InputStreamReader(this, charset) - -/** Creates a buffered reader on this input stream using the specified [charset]. */ -@Deprecated("Use InputStream.bufferedReader(Charset) instead.", ReplaceWith("this.bufferedReader(charset(charset))"), level = DeprecationLevel.ERROR) -public fun InputStream.bufferedReader(charset: String): BufferedReader = reader(charset(charset)).buffered() - /** * Creates a buffered output stream wrapping this stream. * @param bufferSize the buffer size to use. @@ -98,14 +90,6 @@ public inline fun OutputStream.writer(charset: Charset = Charsets.UTF_8): Output @kotlin.internal.InlineOnly public inline fun OutputStream.bufferedWriter(charset: Charset = Charsets.UTF_8): BufferedWriter = writer(charset).buffered() -/** Creates a writer on this output stream using the specified [charset]. */ -@Deprecated("Use OutputStream.writer(Charset) instead.", ReplaceWith("this.writer(charset(charset))"), level = DeprecationLevel.ERROR) -public fun OutputStream.writer(charset: String): OutputStreamWriter = OutputStreamWriter(this, charset) - -/** Creates a buffered writer on this output stream using the specified [charset]. */ -@Deprecated("Use OutputStream.bufferedWriter(Charset) instead.", ReplaceWith("this.bufferedWriter(charset(charset))"), level = DeprecationLevel.ERROR) -public fun OutputStream.bufferedWriter(charset: String): BufferedWriter = writer(charset(charset)).buffered() - /** * Copies this stream to the given output stream, returning the number of bytes copied * diff --git a/libraries/stdlib/src/kotlin/io/ReadWrite.kt b/libraries/stdlib/src/kotlin/io/ReadWrite.kt index 46d96f5be5e..61d360ec283 100644 --- a/libraries/stdlib/src/kotlin/io/ReadWrite.kt +++ b/libraries/stdlib/src/kotlin/io/ReadWrite.kt @@ -122,17 +122,6 @@ public fun Reader.copyTo(out: Writer, bufferSize: Int = DEFAULT_BUFFER_SIZE): Lo return charsCopied } -/** - * Reads the entire content of this URL as a String using the specified [charset]. - * - * This method is not recommended on huge files. - * - * @param charset a character set to use. - * @return a string with this URL entire content. - */ -@Deprecated("Use URL.readText(Charset) instead.", ReplaceWith("this.readText(charset(charset))"), level = DeprecationLevel.ERROR) -public fun URL.readText(charset: String): String = readBytes().toString(charset(charset)) - /** * Reads the entire content of this URL as a String using UTF-8 or the specified [charset]. * diff --git a/libraries/stdlib/src/kotlin/io/files/Utils.kt b/libraries/stdlib/src/kotlin/io/files/Utils.kt index 1b34b7dc559..dbd0a6789b0 100644 --- a/libraries/stdlib/src/kotlin/io/files/Utils.kt +++ b/libraries/stdlib/src/kotlin/io/files/Utils.kt @@ -87,10 +87,6 @@ public fun File.toRelativeString(base: File): String */ public fun File.relativeTo(base: File): File = File(this.toRelativeString(base)) -@Deprecated("Use relativeTo instead.", ReplaceWith("this.relativeTo(base)"), level = DeprecationLevel.ERROR) -public fun File.relativeToFile(base: File): File = File(this.toRelativeString(base)) - - /** * Calculates the relative path for this file from [base] file. * Note that the [base] file is treated as a directory. diff --git a/libraries/stdlib/src/kotlin/system/Timing.kt b/libraries/stdlib/src/kotlin/system/Timing.kt index df6f2d9f246..66cc26b2011 100644 --- a/libraries/stdlib/src/kotlin/system/Timing.kt +++ b/libraries/stdlib/src/kotlin/system/Timing.kt @@ -19,9 +19,3 @@ public inline fun measureNanoTime(block: () -> Unit) : Long { block() return System.nanoTime() - start } - -/** - * Executes the given block and returns elapsed time in nanoseconds. - */ -@Deprecated("Use measureNanoTime.", ReplaceWith("measureNanoTime(block)"), level = DeprecationLevel.ERROR) -public inline fun measureTimeNano(block: () -> Unit) : Long = measureNanoTime(block) diff --git a/libraries/stdlib/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/src/kotlin/text/StringsJVM.kt index b1153841f19..9ef02aa110f 100644 --- a/libraries/stdlib/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/src/kotlin/text/StringsJVM.kt @@ -199,18 +199,6 @@ public fun String.endsWith(suffix: String, ignoreCase: Boolean = false): Boolean // "constructors" for String -/** - * Converts the data from a portion of the specified array of bytes to characters using the specified character set - * and returns the conversion result as a string. - * - * @param bytes the source array for the conversion. - * @param offset the offset in the array of the data to be converted. - * @param length the number of bytes to be converted. - * @param charsetName the name of the character set to use. - */ -@Deprecated("Use String(bytes, offset, length, Charset) instead.", ReplaceWith("String(bytes, offset, length, charset(charsetName))"), level = DeprecationLevel.ERROR) -public fun String(bytes: ByteArray, offset: Int, length: Int, charsetName: String): String = java.lang.String(bytes, offset, length, charsetName) as String - /** * Converts the data from a portion of the specified array of bytes to characters using the specified character set * and returns the conversion result as a string. @@ -223,13 +211,6 @@ public fun String(bytes: ByteArray, offset: Int, length: Int, charsetName: Strin @kotlin.internal.InlineOnly public inline fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String = java.lang.String(bytes, offset, length, charset) as String -/** - * Converts the data from the specified array of bytes to characters using the specified character set - * and returns the conversion result as a string. - */ -@Deprecated("Use String(bytes, Charset) instead.", ReplaceWith("String(bytes, charset(charsetName))"), level = DeprecationLevel.ERROR) -public fun String(bytes: ByteArray, charsetName: String): String = java.lang.String(bytes, charsetName) as String - /** * Converts the data from the specified array of bytes to characters using the specified character set * and returns the conversion result as a string. @@ -313,12 +294,6 @@ public fun String.compareTo(other: String, ignoreCase: Boolean = false): Int { return (this as java.lang.String).compareTo(other) } -/** - * Returns a new string obtained by concatenating this string and the specified string. - */ -@Deprecated("Use this + other, eventually it will be optimized as concat.", ReplaceWith("this + other"), level = DeprecationLevel.ERROR) -public fun String.concat(other: String): String = (this as java.lang.String).concat(other) - /** * Returns `true` if this string is equal to the contents of the specified CharSequence. */ @@ -435,12 +410,6 @@ public inline fun String.toFloat(): Float = java.lang.Float.parseFloat(this) @kotlin.internal.InlineOnly public inline fun String.toDouble(): Double = java.lang.Double.parseDouble(this) -/** - * Encodes the contents of this string using the specified character set and returns the resulting byte array. - */ -@Deprecated("Use String.toByteArray(Charset) instead.", ReplaceWith("this.toByteArray(charset(charset))"), level = DeprecationLevel.ERROR) -public fun String.toByteArray(charset: String): ByteArray = (this as java.lang.String).getBytes(charset) - /** * Encodes the contents of this string using the specified character set and returns the resulting byte array. */ @@ -495,33 +464,6 @@ public fun CharSequence.repeat(n: Int): String { return sb.toString() } -/** - * Appends the contents of this char sequence, excluding the first characters that satisfy the given [predicate], - * to the given Appendable. - */ -@Deprecated("This function will be removed soon.", ReplaceWith("result.append(this.dropWhile(predicate))"), level = DeprecationLevel.ERROR) -public inline fun CharSequence.dropWhileTo(result: T, predicate: (Char) -> Boolean): T { - var start = true - for (element in this) { - if (start && predicate(element)) { - // ignore - } else { - start = false - result.append(element) - } - } - return result -} - -/** - * Appends the first characters from this char sequence that satisfy the given [predicate] to the given Appendable. - */ -@Deprecated("This function will be removed soon.", ReplaceWith("result.append(this.takeWhile(predicate))"), level = DeprecationLevel.ERROR) -public inline fun CharSequence.takeWhileTo(result: T, predicate: (Char) -> Boolean): T { - for (c in this) if (predicate(c)) result.append(c) else break - return result -} - /** * A Comparator that orders strings ignoring character case. diff --git a/libraries/stdlib/src/kotlin/util/OrderingDeprecated.kt b/libraries/stdlib/src/kotlin/util/OrderingDeprecated.kt deleted file mode 100644 index 94b802d2e0b..00000000000 --- a/libraries/stdlib/src/kotlin/util/OrderingDeprecated.kt +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright 2010-2014 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("ComparisonsKt") -@file:Suppress("DEPRECATION_ERROR") - -package kotlin - -import java.util.Comparator - -/** - * Compares two values using the specified functions [selectors] to calculate the result of the comparison. - * The functions are called sequentially, receive the given values [a] and [b] and return [Comparable] - * objects. As soon as the [Comparable] instances returned by a function for [a] and [b] values do not - * compare as equal, the result of that comparison is returned. - */ -@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, *selectors)", "kotlin.comparisons.compareValuesBy"), level = DeprecationLevel.ERROR) -public fun compareValuesBy(a: T, b: T, vararg selectors: (T) -> Comparable<*>?): Int { - require(selectors.size > 0) - for (fn in selectors) { - val v1 = fn(a) - val v2 = fn(b) - val diff = compareValues(v1, v2) - if (diff != 0) return diff - } - return 0 -} - -/** - * Compares two values using the specified [selector] function to calculate the result of the comparison. - * The function is applied to the given values [a] and [b] and return [Comparable] objects. - * The result of comparison of these [Comparable] instances is returned. - */ -@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, selector)", "kotlin.comparisons.compareValuesBy"), level = DeprecationLevel.ERROR) -public inline fun compareValuesBy(a: T, b: T, selector: (T) -> Comparable<*>?): Int { - return compareValues(selector(a), selector(b)) -} - -/** - * Compares two values using the specified [selector] function to calculate the result of the comparison. - * The function is applied to the given values [a] and [b] and return objects of type K which are then being - * compared with the given [comparator]. - */ -@Deprecated("Use compareValuesBy from kotlin.comparisons package.", ReplaceWith("compareValuesBy(a, b, comparator, selector)", "kotlin.comparisons.compareValuesBy"), level = DeprecationLevel.ERROR) -public inline fun compareValuesBy(a: T, b: T, comparator: Comparator, selector: (T) -> K): Int { - return comparator.compare(selector(a), selector(b)) -} - -//// Not so useful without type inference for receiver of expression -//// compareValuesWith(v1, v2, compareBy { it.prop1 } thenByDescending { it.prop2 }) -///** -// * Compares two values using the specified [comparator]. -// */ -//@Suppress("NOTHING_TO_INLINE") -//public inline fun compareValuesWith(a: T, b: T, comparator: Comparator): Int = comparator.compare(a, b) -// - - -/** - * Compares two nullable [Comparable] values. Null is considered less than any value. - */ -@Deprecated("Use compareValues from kotlin.comparisons package.", ReplaceWith("compareValues(a, b)", "kotlin.comparisons.compareValues"), level = DeprecationLevel.ERROR) -public fun > compareValues(a: T?, b: T?): Int { - if (a === b) return 0 - if (a == null) return -1 - if (b == null) return 1 - - return (a as Comparable).compareTo(b) -} - -/** - * Creates a comparator using the sequence of functions to calculate a result of comparison. - * The functions are called sequentially, receive the given values `a` and `b` and return [Comparable] - * objects. As soon as the [Comparable] instances returned by a function for `a` and `b` values do not - * compare as equal, the result of that comparison is returned from the [Comparator]. - */ -@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(*selectors)", "kotlin.comparisons.compareBy"), level = DeprecationLevel.ERROR) -public fun compareBy(vararg selectors: (T) -> Comparable<*>?): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, *selectors) - } -} - - - -/** - * Creates a comparator using the function to transform value to a [Comparable] instance for comparison. - */ -@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(selector)", "kotlin.comparisons.compareBy"), level = DeprecationLevel.ERROR) -inline public fun compareBy(crossinline selector: (T) -> Comparable<*>?): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, selector) - } -} - -/** - * Creates a comparator using the [selector] function to transform values being compared and then applying - * the specified [comparator] to compare transformed values. - */ -@Deprecated("Use compareBy from kotlin.comparisons package.", ReplaceWith("compareBy(comparator, selector)", "kotlin.comparisons.compareBy"), level = DeprecationLevel.ERROR) -inline public fun compareBy(comparator: Comparator, crossinline selector: (T) -> K): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int = compareValuesBy(a, b, comparator, selector) - } -} - -/** - * Creates a descending comparator using the function to transform value to a [Comparable] instance for comparison. - */ -@Deprecated("Use compareByDescending from kotlin.comparisons package.", ReplaceWith("compareByDescending(selector)", "kotlin.comparisons.compareByDescending"), level = DeprecationLevel.ERROR) -inline public fun compareByDescending(crossinline selector: (T) -> Comparable<*>?): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int = compareValuesBy(b, a, selector) - } -} - -/** - * Creates a descending comparator using the [selector] function to transform values being compared and then applying - * the specified [comparator] to compare transformed values. - * - * Note that an order of [comparator] is reversed by this wrapper. - */ -@Deprecated("Use compareByDescending from kotlin.comparisons package.", ReplaceWith("compareByDescending(comparator, selector)", "kotlin.comparisons.compareByDescending"), level = DeprecationLevel.ERROR) -inline public fun compareByDescending(comparator: Comparator, crossinline selector: (T) -> K): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int = compareValuesBy(b, a, comparator, selector) - } -} - -/** - * Creates a comparator comparing values after the primary comparator defined them equal. It uses - * the function to transform value to a [Comparable] instance for comparison. - */ -@Deprecated("Use thenBy from kotlin.comparisons package.", ReplaceWith("this.thenBy(selector)", "kotlin.comparisons.thenBy"), level = DeprecationLevel.ERROR) -inline public fun Comparator.thenBy(crossinline selector: (T) -> Comparable<*>?): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@thenBy.compare(a, b) - return if (previousCompare != 0) previousCompare else compareValuesBy(a, b, selector) - } - } -} - -/** - * Creates a comparator comparing values after the primary comparator defined them equal. It uses - * the [selector] function to transform values and then compares them with the given [comparator]. - */ -@Deprecated("Use thenBy from kotlin.comparisons package.", ReplaceWith("this.thenBy(comparator, selector)", "kotlin.comparisons.thenBy"), level = DeprecationLevel.ERROR) -inline public fun Comparator.thenBy(comparator: Comparator, crossinline selector: (T) -> K): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@thenBy.compare(a, b) - return if (previousCompare != 0) previousCompare else compareValuesBy(a, b, comparator, selector) - } - } -} - -/** - * Creates a descending comparator using the primary comparator and - * the function to transform value to a [Comparable] instance for comparison. - */ -@Deprecated("Use thenByDescending from kotlin.comparisons package.", ReplaceWith("this.thenByDescending(selector)", "kotlin.comparisons.thenByDescending"), level = DeprecationLevel.ERROR) -inline public fun Comparator.thenByDescending(crossinline selector: (T) -> Comparable<*>?): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@thenByDescending.compare(a, b) - return if (previousCompare != 0) previousCompare else compareValuesBy(b, a, selector) - } - } -} - -/** - * Creates a descending comparator comparing values after the primary comparator defined them equal. It uses - * the [selector] function to transform values and then compares them with the given [comparator]. - */ -@Deprecated("Use thenByDescending from kotlin.comparisons package.", ReplaceWith("this.thenByDescending(comparator, selector)", "kotlin.comparisons.thenByDescending"), level = DeprecationLevel.ERROR) -inline public fun Comparator.thenByDescending(comparator: Comparator, crossinline selector: (T) -> K): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@thenByDescending.compare(a, b) - return if (previousCompare != 0) previousCompare else compareValuesBy(b, a, comparator, selector) - } - } -} - -/** - * Creates a comparator using the function to calculate a result of comparison. - */ -@Deprecated("Use Comparator SAM-constructor instead.", ReplaceWith("Comparator(comparison)", "java.util.Comparator"), level = DeprecationLevel.ERROR) -inline public fun comparator(crossinline comparison: (T, T) -> Int) = Comparator { a, b -> comparison(a, b) } - -/** - * Creates a comparator using the primary comparator and function to calculate a result of comparison. - */ -@Deprecated("Use thenComparator from kotlin.comparisons package.", ReplaceWith("this.thenComparator(comparison)", "kotlin.comparisons.thenComparator"), level = DeprecationLevel.ERROR) -inline public fun Comparator.thenComparator(crossinline comparison: (T, T) -> Int): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@thenComparator.compare(a, b) - return if (previousCompare != 0) previousCompare else comparison(a, b) - } - } -} - -/** - * Combines this comparator and the given [comparator] such that the latter is applied only - * when the former considered values equal. - */ -@Deprecated("Use then from kotlin.comparisons package.", ReplaceWith("this.then(comparator)", "kotlin.comparisons.then"), level = DeprecationLevel.ERROR) -public infix fun Comparator.then(comparator: Comparator): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@then.compare(a, b) - return if (previousCompare != 0) previousCompare else comparator.compare(a, b) - } - } -} - -/** - * Combines this comparator and the given [comparator] such that the latter is applied only - * when the former considered values equal. - */ -@Deprecated("Use thenDescending from kotlin.comparisons package.", ReplaceWith("this.thenDescending(comparator)", "kotlin.comparisons.thenDescending"), level = DeprecationLevel.ERROR) -public infix fun Comparator.thenDescending(comparator: Comparator): Comparator { - return object : Comparator { - public override fun compare(a: T, b: T): Int { - val previousCompare = this@thenDescending.compare(a, b) - return if (previousCompare != 0) previousCompare else comparator.compare(b, a) - } - } -} - -// Not so useful without type inference for receiver of expression -/** - * Extends the given [comparator] of non-nullable values to a comparator of nullable values - * considering `null` value less than any other value. - */ -@Deprecated("Use nullsFirst from kotlin.comparisons package.", ReplaceWith("nullsFirst(comparator)", "kotlin.comparisons.nullsFirst"), level = DeprecationLevel.ERROR) -public fun nullsFirst(comparator: Comparator): Comparator { - return object: Comparator { - override fun compare(a: T?, b: T?): Int { - if (a === b) return 0 - if (a == null) return -1 - if (b == null) return 1 - return comparator.compare(a, b) - } - } -} - -/** - * Provides a comparator of nullable [Comparable] values - * considering `null` value less than any other value. - */ -@Deprecated("Use nullsFirst from kotlin.comparisons package.", ReplaceWith("nullsFirst()", "kotlin.comparisons.nullsFirst"), level = DeprecationLevel.ERROR) -public fun > nullsFirst(): Comparator = nullsFirst(naturalOrder()) - -/** - * Extends the given [comparator] of non-nullable values to a comparator of nullable values - * considering `null` value greater than any other value. - */ -@Deprecated("Use nullsLast from kotlin.comparisons package.", ReplaceWith("nullsLast(comparator)", "kotlin.comparisons.nullsLast"), level = DeprecationLevel.ERROR) -public fun nullsLast(comparator: Comparator): Comparator { - return object: Comparator { - override fun compare(a: T?, b: T?): Int { - if (a === b) return 0 - if (a == null) return 1 - if (b == null) return -1 - return comparator.compare(a, b) - } - } -} - -/** - * Provides a comparator of nullable [Comparable] values - * considering `null` value greater than any other value. - */ -@Deprecated("Use nullsLast from kotlin.comparisons package.", ReplaceWith("nullsLast()", "kotlin.comparisons.nullsLast"), level = DeprecationLevel.ERROR) -public fun > nullsLast(): Comparator = nullsLast(naturalOrder()) - -/** - * Returns a comparator that compares [Comparable] objects in natural order. - */ -@Deprecated("Use naturalOrder from kotlin.comparisons package.", ReplaceWith("naturalOrder()", "kotlin.comparisons.naturalOrder"), level = DeprecationLevel.ERROR) -public fun > naturalOrder(): Comparator = NaturalOrderComparator as Comparator - -/** - * Returns a comparator that compares [Comparable] objects in reversed natural order. - */ -@Deprecated("Use reverseOrder from kotlin.comparisons package.", ReplaceWith("reverseOrder()", "kotlin.comparisons.reverseOrder"), level = DeprecationLevel.ERROR) -public fun > reverseOrder(): Comparator = ReverseOrderComparator as Comparator - -/** Returns a comparator that imposes the reverse ordering of this comparator. */ -@Deprecated("Use reversed from kotlin.comparisons package.", ReplaceWith("this.reversed()", "kotlin.comparisons.reversed"), level = DeprecationLevel.ERROR) -public fun Comparator.reversed(): Comparator = when (this) { - is ReversedComparator -> this.comparator - NaturalOrderComparator -> ReverseOrderComparator as Comparator - ReverseOrderComparator -> NaturalOrderComparator as Comparator - else -> ReversedComparator(this) -} - - -private class ReversedComparator(public val comparator: Comparator): Comparator { - override fun compare(a: T, b: T): Int = comparator.compare(b, a) - @Suppress("VIRTUAL_MEMBER_HIDDEN") - fun reversed(): Comparator = comparator -} - -private object NaturalOrderComparator : Comparator> { - override fun compare(c1: Comparable, c2: Comparable): Int = c1.compareTo(c2) - @Suppress("VIRTUAL_MEMBER_HIDDEN") - fun reversed(): Comparator> = ReverseOrderComparator -} - -private object ReverseOrderComparator: Comparator> { - override fun compare(c1: Comparable, c2: Comparable): Int = c2.compareTo(c1) - @Suppress("VIRTUAL_MEMBER_HIDDEN") - fun reversed(): Comparator> = NaturalOrderComparator -} diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index e724c8711c0..bc01a6f23b2 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -60,30 +60,6 @@ fun snapshots(): List { body { "return toCollection(TreeSet(comparator))" } } - templates add f("toArrayList()") { - doc { f -> "Returns an [ArrayList] of all ${f.element.pluralize()}." } - returns("ArrayList") - body { "return toCollection(ArrayList())" } - body(Iterables) { - """ - if (this is Collection) - return ArrayList(this) - return toCollection(ArrayList()) - """ - } - body(Collections) { "return ArrayList(this)" } - body(CharSequences) { "return toCollection(ArrayList(length))" } - body(ArraysOfObjects) { "return ArrayList(this.asCollection())" } - body(ArraysOfPrimitives) { - """ - val list = ArrayList(size) - for (item in this) list.add(item) - return list - """ - } - deprecate(Deprecation("Use toMutableList instead or toCollection(ArrayList()) if you need ArrayList's ensureCapacity and trimToSize.", "toCollection(arrayListOf())", level = DeprecationLevel.ERROR)) - } - templates add f("toMutableList()") { doc { f -> "Returns a [MutableList] filled with all ${f.element.pluralize()} of this ${f.collection}." } returns("MutableList") @@ -128,16 +104,6 @@ fun snapshots(): List { body { "return this.toMutableList()" } } - templates add f("toMap(transform: (T) -> Pair)") { - inline(true) - include(CharSequences) - typeParam("K") - typeParam("V") - returns("Map") - annotations("""@kotlin.jvm.JvmName("toMapOfPairs")""") - deprecate(Deprecation("Use associate instead.", replaceWith = "associate(transform)", level = DeprecationLevel.ERROR)) - } - templates add f("associate(transform: (T) -> Pair)") { inline(true) include(CharSequences) @@ -203,14 +169,6 @@ fun snapshots(): List { } } - templates add f("toMapBy(selector: (T) -> K)") { - inline(true) - typeParam("K") - returns("Map") - include(CharSequences) - deprecate(Deprecation("Use associateBy instead.", replaceWith = "associateBy(selector)", level = DeprecationLevel.ERROR)) - } - templates add f("associateBy(keySelector: (T) -> K)") { inline(true) include(CharSequences) @@ -281,30 +239,6 @@ fun snapshots(): List { } } - templates add f("toMap(selector: (T) -> K, transform: (T) -> V)") { - inline(true) - include(CharSequences) - typeParam("K") - typeParam("V") - doc { f -> - """ - Returns a [Map] containing the values provided by [transform] and indexed by [selector] functions applied to ${f.element.pluralize()} of the given ${f.collection}. - If any two ${f.element.pluralize()} would have the same key returned by [selector] the last one gets added to the map. - """ - } - returns("Map") - deprecate(Deprecation("Use associateBy instead.", "associateBy(selector, transform)", level = DeprecationLevel.ERROR)) - } - - templates add f("toMapBy(selector: (T) -> K, transform: (T) -> V)") { - inline(true) - typeParam("K") - typeParam("V") - include(CharSequences) - returns("Map") - deprecate(Deprecation("Use associateBy instead.", replaceWith = "associateBy(selector, transform)", level = DeprecationLevel.ERROR)) - } - templates add f("associateBy(keySelector: (T) -> K, valueTransform: (T) -> V)") { inline(true) include(CharSequences)