From 33b366b9b96b9f2badd72bd61da7783f5e18cc9e Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 30 Nov 2015 18:19:25 +0300 Subject: [PATCH] Relax upper bound of T for minBy and maxBy to be nullable. Swap type parameters of minBy and maxBy. #KT-10099 Fixed --- libraries/stdlib/src/generated/_Arrays.kt | 4 ++-- libraries/stdlib/src/generated/_Collections.kt | 4 ++-- libraries/stdlib/src/generated/_Sequences.kt | 4 ++-- libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/stdlib/src/generated/_Arrays.kt b/libraries/stdlib/src/generated/_Arrays.kt index 654d0d3674c..2b397bf8881 100644 --- a/libraries/stdlib/src/generated/_Arrays.kt +++ b/libraries/stdlib/src/generated/_Arrays.kt @@ -8359,7 +8359,7 @@ public fun ShortArray.max(): Short? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Array.maxBy(selector: (T) -> R): T? { +public inline fun > Array.maxBy(selector: (T) -> R): T? { if (isEmpty()) return null var maxElem = this[0] var maxValue = selector(maxElem) @@ -8625,7 +8625,7 @@ public fun ShortArray.min(): Short? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Array.minBy(selector: (T) -> R): T? { +public inline fun > Array.minBy(selector: (T) -> R): T? { if (isEmpty()) return null var minElem = this[0] var minValue = selector(minElem) diff --git a/libraries/stdlib/src/generated/_Collections.kt b/libraries/stdlib/src/generated/_Collections.kt index cd701c6d323..9d51a97a598 100644 --- a/libraries/stdlib/src/generated/_Collections.kt +++ b/libraries/stdlib/src/generated/_Collections.kt @@ -1397,7 +1397,7 @@ public fun > Iterable.max(): T? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Iterable.maxBy(selector: (T) -> R): T? { +public inline fun > Iterable.maxBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var maxElem = iterator.next() @@ -1430,7 +1430,7 @@ public fun > Iterable.min(): T? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Iterable.minBy(selector: (T) -> R): T? { +public inline fun > Iterable.minBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var minElem = iterator.next() diff --git a/libraries/stdlib/src/generated/_Sequences.kt b/libraries/stdlib/src/generated/_Sequences.kt index 05595ba2861..31c08e9277c 100644 --- a/libraries/stdlib/src/generated/_Sequences.kt +++ b/libraries/stdlib/src/generated/_Sequences.kt @@ -799,7 +799,7 @@ public fun > Sequence.max(): T? { /** * Returns the first element yielding the largest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Sequence.maxBy(selector: (T) -> R): T? { +public inline fun > Sequence.maxBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var maxElem = iterator.next() @@ -832,7 +832,7 @@ public fun > Sequence.min(): T? { /** * Returns the first element yielding the smallest value of the given function or `null` if there are no elements. */ -public inline fun , T : Any> Sequence.minBy(selector: (T) -> R): T? { +public inline fun > Sequence.minBy(selector: (T) -> R): T? { val iterator = iterator() if (!iterator.hasNext()) return null var minElem = iterator.next() diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt index 1b39d1b7b15..1fa549f4cff 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Aggregates.kt @@ -181,8 +181,8 @@ fun aggregates(): List { inline(true) doc { f -> "Returns the first ${f.element} yielding the smallest value of the given function or `null` if there are no ${f.element.pluralize()}." } + typeParam("T") typeParam("R : Comparable") - typeParam("T : Any") returns("T?") body { """ @@ -287,8 +287,8 @@ fun aggregates(): List { inline(true) doc { f -> "Returns the first ${f.element} yielding the largest value of the given function or `null` if there are no ${f.element.pluralize()}." } + typeParam("T") typeParam("R : Comparable") - typeParam("T : Any") returns("T?") body { """