Temporary drop mapNotNull and mapNotNullTo.
Disable mapNotNull tests #KT-4410
This commit is contained in:
@@ -6545,28 +6545,6 @@ public inline fun <R, C : MutableCollection<in R>> 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 <T : Any, R> Array<out T?>.mapNotNull(transform: (T) -> R): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), 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 <T : Any, R, C : MutableCollection<in R>> Array<out T?>.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].
|
||||
|
||||
@@ -1081,28 +1081,6 @@ public inline fun <T, R, C : MutableCollection<in R>> Iterable<T>.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 <T : Any, R> Iterable<T?>.mapNotNull(transform: (T) -> R): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), 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 <T : Any, R, C : MutableCollection<in R>> Iterable<T?>.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].
|
||||
|
||||
@@ -606,28 +606,6 @@ public inline fun <T, R, C : MutableCollection<in R>> Sequence<T>.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 <T : Any, R> Sequence<T?>.mapNotNull(transform: (T) -> R): Sequence<R> {
|
||||
return TransformingSequence(FilteringSequence(this, false, { it == null }) as Sequence<T>, 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 <T : Any, R, C : MutableCollection<in R>> Sequence<T?>.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].
|
||||
|
||||
@@ -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<Int>
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@test fun listOfNotNull() {
|
||||
val l1: List<Int> = listOfNotNull(null)
|
||||
|
||||
@@ -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<Int>
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@test fun mapIndexed() {
|
||||
assertEquals(listOf(0, 1, 2, 6, 12), fibonacci().mapIndexed { index, value -> index * value }.takeWhile { i: Int -> i < 20 }.toList())
|
||||
|
||||
@@ -71,6 +71,7 @@ fun mapping(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
/*
|
||||
templates add f("mapNotNull(transform: (T) -> R)") {
|
||||
inline(true)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
@@ -95,6 +96,7 @@ fun mapping(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
templates add f("mapTo(destination: C, transform: (T) -> R)") {
|
||||
inline(true)
|
||||
@@ -143,6 +145,7 @@ fun mapping(): List<GenericFunction> {
|
||||
include(Maps)
|
||||
}
|
||||
|
||||
/*
|
||||
templates add f("mapNotNullTo(destination: C, transform: (T) -> R)") {
|
||||
inline(true)
|
||||
exclude(Strings, ArraysOfPrimitives)
|
||||
@@ -170,6 +173,7 @@ fun mapping(): List<GenericFunction> {
|
||||
"""
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
templates add f("flatMap(transform: (T) -> Iterable<R>)") {
|
||||
inline(true)
|
||||
|
||||
Reference in New Issue
Block a user