From 362e463b26e024c72f50c384b9ae61badbae1c7b Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 28 Dec 2015 19:29:03 +0300 Subject: [PATCH] Preserve type projection for Array.requireNoNulls. #KT-10039 Fixed --- libraries/stdlib/src/generated/_Arrays.kt | 4 ++-- libraries/tools/kotlin-stdlib-gen/src/templates/Guards.kt | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) 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