Stdlib update due ONLY_LOCAL_RETURN diagnostic

This commit is contained in:
Michael Bogdanov
2014-06-17 18:18:06 +04:00
parent ce71c5abde
commit a1a205a3db
3 changed files with 8 additions and 8 deletions
+4 -4
View File
@@ -134,7 +134,7 @@ public fun <T> Iterable<T>.sortBy(comparator: Comparator<T>): List<T> {
/**
* Returns a sorted list of all elements, ordered by results of specified *order* function.
*/
public inline fun <T, R : Comparable<R>> Array<out T>.sortBy(order: (T) -> R): List<T> {
public inline fun <T, R : Comparable<R>> Array<out T>.sortBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
java.util.Collections.sort(sortedList, sortBy)
@@ -144,7 +144,7 @@ public inline fun <T, R : Comparable<R>> Array<out T>.sortBy(order: (T) -> R): L
/**
* Returns a sorted list of all elements, ordered by results of specified *order* function.
*/
public inline fun <T, R : Comparable<R>> Iterable<T>.sortBy(order: (T) -> R): List<T> {
public inline fun <T, R : Comparable<R>> Iterable<T>.sortBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> order(x).compareTo(order(y)) }
java.util.Collections.sort(sortedList, sortBy)
@@ -164,7 +164,7 @@ public fun <T : Comparable<T>> Iterable<T>.sortDescending(): List<T> {
/**
* Returns a sorted list of all elements, in descending order by results of specified *order* function.
*/
public inline fun <T, R : Comparable<R>> Array<out T>.sortDescendingBy(order: (T) -> R): List<T> {
public inline fun <T, R : Comparable<R>> Array<out T>.sortDescendingBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y)) }
java.util.Collections.sort(sortedList, sortBy)
@@ -174,7 +174,7 @@ public inline fun <T, R : Comparable<R>> Array<out T>.sortDescendingBy(order: (T
/**
* Returns a sorted list of all elements, in descending order by results of specified *order* function.
*/
public inline fun <T, R : Comparable<R>> Iterable<T>.sortDescendingBy(order: (T) -> R): List<T> {
public inline fun <T, R : Comparable<R>> Iterable<T>.sortDescendingBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) order: (T) -> R): List<T> {
val sortedList = toArrayList()
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) -> -order(x).compareTo(order(y)) }
java.util.Collections.sort(sortedList, sortBy)
@@ -100,7 +100,7 @@ public fun <T> Iterator<T>.filter(predicate: (T) -> Boolean) : Iterator<T> {
* Returns an iterator over elements which don't match the given *predicate*
*/
deprecated("Replace Iterator<T> with Stream<T> by using stream() function instead of iterator()")
public inline fun <T> Iterator<T>.filterNot(predicate: (T) -> Boolean) : Iterator<T> {
public inline fun <T> Iterator<T>.filterNot(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) predicate: (T) -> Boolean) : Iterator<T> {
return filter {!predicate(it)}
}
@@ -392,7 +392,7 @@ public fun <T> Iterator<T>.reverse() : List<T> {
* E.g. arrayList("two" to 2, "one" to 1).sortBy({it.second}) returns list sorted by second element of pair
*/
deprecated("Replace Iterator<T> with Stream<T> by using stream() function instead of iterator()")
public inline fun <T, R: Comparable<R>> Iterator<T>.sortBy(f: (T) -> R) : List<T> {
public inline fun <T, R: Comparable<R>> Iterator<T>.sortBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) f: (T) -> R) : List<T> {
val sortedList = toCollection(ArrayList<T>())
val sortBy: Comparator<T> = comparator<T> {(x: T, y: T) ->
val xr = f(x)
@@ -92,7 +92,7 @@ fun ordering(): List<GenericFunction> {
exclude(Strings)
}
templates add f("sortBy(order: (T) -> R)") {
templates add f("sortBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) order: (T) -> R)") {
inline(true)
doc {
@@ -137,7 +137,7 @@ fun ordering(): List<GenericFunction> {
only(Streams, ArraysOfObjects, ArraysOfPrimitives, Iterables)
}
templates add f("sortDescendingBy(order: (T) -> R)") {
templates add f("sortDescendingBy(inlineOptions(InlineOption.ONLY_LOCAL_RETURN) order: (T) -> R)") {
inline(true)
doc {