Preserve type projection for Array.requireNoNulls.
#KT-10039 Fixed
This commit is contained in:
@@ -9804,13 +9804,13 @@ public inline fun ShortArray.sumByDouble(selector: (Short) -> Double): Double {
|
|||||||
/**
|
/**
|
||||||
* Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.
|
* Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements.
|
||||||
*/
|
*/
|
||||||
public fun <T : Any> Array<out T?>.requireNoNulls(): Array<out T> {
|
public fun <T : Any> Array<T?>.requireNoNulls(): Array<T> {
|
||||||
for (element in this) {
|
for (element in this) {
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
throw IllegalArgumentException("null element found in $this.")
|
throw IllegalArgumentException("null element found in $this.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this as Array<out T>
|
return this as Array<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,8 +8,7 @@ fun guards(): List<GenericFunction> {
|
|||||||
val templates = arrayListOf<GenericFunction>()
|
val templates = arrayListOf<GenericFunction>()
|
||||||
|
|
||||||
templates add f("requireNoNulls()") {
|
templates add f("requireNoNulls()") {
|
||||||
include(Lists)
|
only(Iterables, Sequences, InvariantArraysOfObjects, Lists)
|
||||||
exclude(Strings, ArraysOfPrimitives)
|
|
||||||
doc { "Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements." }
|
doc { "Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements." }
|
||||||
typeParam("T : Any")
|
typeParam("T : Any")
|
||||||
toNullableT = true
|
toNullableT = true
|
||||||
|
|||||||
Reference in New Issue
Block a user