diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 49e07b99d06..7502232b92a 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -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. */ -public fun Array.requireNoNulls(): Array { +public fun Array.requireNoNulls(): Array { for (element in this) { if (element == null) { throw IllegalArgumentException("null element found in $this.") } } - return this as Array + return this as Array } /** diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt index bd8498198e0..61fb702b8b4 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt @@ -8,8 +8,7 @@ fun guards(): List { val templates = arrayListOf() templates add f("requireNoNulls()") { - include(Lists) - exclude(Strings, ArraysOfPrimitives) + only(Iterables, Sequences, InvariantArraysOfObjects, Lists) doc { "Returns an original collection containing all the non-`null` elements, throwing an [IllegalArgumentException] if there are any `null` elements." } typeParam("T : Any") toNullableT = true