From 65a98d6968833f983bda53dd924f052e0cffafbd Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Fri, 30 Oct 2015 17:14:04 +0300 Subject: [PATCH] Temporary drop mapNotNull and mapNotNullTo. Disable mapNotNull tests #KT-4410 --- libraries/stdlib/src/generated/_Arrays.kt | 22 ------------------- .../stdlib/src/generated/_Collections.kt | 22 ------------------- libraries/stdlib/src/generated/_Sequences.kt | 22 ------------------- .../stdlib/test/collections/CollectionTest.kt | 2 ++ .../stdlib/test/collections/SequenceTest.kt | 2 ++ .../src/templates/Mapping.kt | 4 ++++ 6 files changed, 8 insertions(+), 66 deletions(-) diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 30bc7f3fae1..865fb7060a6 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -6545,28 +6545,6 @@ public inline fun > ShortArray.mapIndexedTo(desti return destination } -/** - * Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection. - */ -@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.", ReplaceWith("filterNotNull().map(transform)")) -public inline fun Array.mapNotNull(transform: (T) -> R): List { - return mapNotNullTo(ArrayList(), transform) -} - -/** - * Appends transformed non-null elements of original collection using the given [transform] function - * to the given [destination]. - */ -@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.", ReplaceWith("filterNotNull().mapTo(destination, transform)")) -public inline fun > Array.mapNotNullTo(destination: C, transform: (T) -> R): C { - for (element in this) { - if (element != null) { - destination.add(transform(element)) - } - } - return destination -} - /** * Appends transformed elements of the original collection using the given [transform] function * to the given [destination]. diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index 5630a8833e8..9c28012ae76 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -1081,28 +1081,6 @@ public inline fun > Iterable.mapIndexedTo(d return destination } -/** - * Returns a list containing the results of applying the given [transform] function to each non-null element of the original collection. - */ -@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.", ReplaceWith("filterNotNull().map(transform)")) -public inline fun Iterable.mapNotNull(transform: (T) -> R): List { - return mapNotNullTo(ArrayList(), transform) -} - -/** - * Appends transformed non-null elements of original collection using the given [transform] function - * to the given [destination]. - */ -@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.", ReplaceWith("filterNotNull().mapTo(destination, transform)")) -public inline fun > Iterable.mapNotNullTo(destination: C, transform: (T) -> R): C { - for (element in this) { - if (element != null) { - destination.add(transform(element)) - } - } - return destination -} - /** * Appends transformed elements of the original collection using the given [transform] function * to the given [destination]. diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 7865e0ce0e9..a964d34c584 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -606,28 +606,6 @@ public inline fun > Sequence.mapIndexedTo(d return destination } -/** - * Returns a sequence containing the results of applying the given [transform] function to each non-null element of the original sequence. - */ -@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().map {} instead.", ReplaceWith("filterNotNull().map(transform)")) -public fun Sequence.mapNotNull(transform: (T) -> R): Sequence { - return TransformingSequence(FilteringSequence(this, false, { it == null }) as Sequence, transform) -} - -/** - * Appends transformed non-null elements of original collection using the given [transform] function - * to the given [destination]. - */ -@Deprecated("This function will change its semantics soon to map&filter rather than filter&map. Use filterNotNull().mapTo(destination) {} instead.", ReplaceWith("filterNotNull().mapTo(destination, transform)")) -public inline fun > Sequence.mapNotNullTo(destination: C, transform: (T) -> R): C { - for (element in this) { - if (element != null) { - destination.add(transform(element)) - } - } - return destination -} - /** * Appends transformed elements of the original collection using the given [transform] function * to the given [destination]. diff --git a/libraries/stdlib/test/collections/CollectionTest.kt b/libraries/stdlib/test/collections/CollectionTest.kt index 157823ba7f7..5b3c9998728 100644 --- a/libraries/stdlib/test/collections/CollectionTest.kt +++ b/libraries/stdlib/test/collections/CollectionTest.kt @@ -36,6 +36,7 @@ class CollectionTest { } } + /* @test fun mapNotNull() { val data = listOf(null, "foo", null, "bar") val foo = data.mapNotNull { it.length() } @@ -46,6 +47,7 @@ class CollectionTest { foo is List } } + */ @test fun listOfNotNull() { val l1: List = listOfNotNull(null) diff --git a/libraries/stdlib/test/collections/SequenceTest.kt b/libraries/stdlib/test/collections/SequenceTest.kt index dfa28d25207..b54a297bd1f 100644 --- a/libraries/stdlib/test/collections/SequenceTest.kt +++ b/libraries/stdlib/test/collections/SequenceTest.kt @@ -63,6 +63,7 @@ public class SequenceTest { assertEquals(listOf("foo", "bar"), filtered.toList()) } + /* @test fun mapNotNull() { val data = sequenceOf(null, "foo", null, "bar") val foo = data.mapNotNull { it.length() } @@ -72,6 +73,7 @@ public class SequenceTest { foo is Sequence } } + */ @test fun mapIndexed() { assertEquals(listOf(0, 1, 2, 6, 12), fibonacci().mapIndexed { index, value -> index * value }.takeWhile { i: Int -> i < 20 }.toList()) diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt index 632b6c9c91e..db6d6c3bbed 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Mapping.kt @@ -71,6 +71,7 @@ fun mapping(): List { include(Maps) } + /* templates add f("mapNotNull(transform: (T) -> R)") { inline(true) exclude(Strings, ArraysOfPrimitives) @@ -95,6 +96,7 @@ fun mapping(): List { """ } } + */ templates add f("mapTo(destination: C, transform: (T) -> R)") { inline(true) @@ -143,6 +145,7 @@ fun mapping(): List { include(Maps) } + /* templates add f("mapNotNullTo(destination: C, transform: (T) -> R)") { inline(true) exclude(Strings, ArraysOfPrimitives) @@ -170,6 +173,7 @@ fun mapping(): List { """ } } + */ templates add f("flatMap(transform: (T) -> Iterable)") { inline(true)