From 3a822252011cc7755199d58514a4446acdb52eeb Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 29 Oct 2015 20:54:06 +0300 Subject: [PATCH] Deprecate toGenerator and toLinkedList extensions. --- libraries/stdlib/src/generated/_Arrays.kt | 27 ++++++++++++------- .../stdlib/src/generated/_Collections.kt | 3 ++- libraries/stdlib/src/generated/_Sequences.kt | 3 ++- libraries/stdlib/src/generated/_Strings.kt | 3 ++- libraries/stdlib/src/kotlin/util/Functions.kt | 1 + .../src/templates/Snapshots.kt | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index ed9ed9260de..30bc7f3fae1 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -5450,64 +5450,73 @@ public fun ShortArray.toHashSet(): HashSet { /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun Array.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun BooleanArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun ByteArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun CharArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun DoubleArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun FloatArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun IntArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun LongArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun ShortArray.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 1ed381a2f9d..5630a8833e8 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -962,8 +962,9 @@ public fun Iterable.toHashSet(): HashSet { /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun Iterable.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 11308c8aba6..7865e0ce0e9 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -489,8 +489,9 @@ public fun Sequence.toHashSet(): HashSet { /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun Sequence.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** diff --git a/libraries/stdlib/src/generated/_Strings.kt b/libraries/stdlib/src/generated/_Strings.kt index 0337fba57e6..7adde39fa9c 100644 --- a/libraries/stdlib/src/generated/_Strings.kt +++ b/libraries/stdlib/src/generated/_Strings.kt @@ -375,8 +375,9 @@ public fun String.toHashSet(): HashSet { /** * Returns a [LinkedList] containing all elements. */ +@Deprecated("Use toCollection(LinkedList()) instead.", ReplaceWith("toCollection(LinkedList())")) public fun String.toLinkedList(): LinkedList { - return toCollection(LinkedList()) + return toCollection(LinkedList()) } /** diff --git a/libraries/stdlib/src/kotlin/util/Functions.kt b/libraries/stdlib/src/kotlin/util/Functions.kt index fb5f0a95822..04c05822fda 100644 --- a/libraries/stdlib/src/kotlin/util/Functions.kt +++ b/libraries/stdlib/src/kotlin/util/Functions.kt @@ -5,6 +5,7 @@ package kotlin * The generator function calls this function, passing to it either [initialValue] on the first iteration * or the previously returned value on subsequent iterations, and returns the returned value. */ +@Deprecated("This function will be removed soon. If you need generator function to create a sequence, use the 'sequence' function instead.") public fun Function1.toGenerator(initialValue: T): Function0 { var nextValue: T? = initialValue return { diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt index cae97629367..6ed4057754d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Snapshots.kt @@ -90,7 +90,7 @@ fun snapshots(): List { templates add f("toLinkedList()") { doc { "Returns a [LinkedList] containing all elements." } returns("LinkedList") - body { "return toCollection(LinkedList())" } + deprecate { Deprecation("Use toCollection(LinkedList()) instead.", replaceWith = "toCollection(LinkedList())") } } templates add f("toMap(selector: (T) -> K)") {