Make stdlib functions dependent on reified is checks available in JS.

#KT-11346 Fixed
This commit is contained in:
Ilya Gorbunov
2016-04-25 19:18:35 +03:00
parent a5fd95c7d9
commit 409094f0f7
10 changed files with 232 additions and 120 deletions
+15 -17
View File
@@ -626,6 +626,21 @@ public inline fun <T, C : MutableCollection<in T>> Iterable<T>.filterIndexedTo(d
return destination
}
/**
* Returns a list containing all elements that are instances of specified type parameter R.
*/
public inline fun <reified R> Iterable<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {
return filterIsInstanceTo(ArrayList<R>())
}
/**
* Appends all elements that are instances of specified type parameter R to the given [destination].
*/
public inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(destination: C): C {
for (element in this) if (element is R) destination.add(element)
return destination
}
/**
* Returns a list containing all elements not matching the given [predicate].
*/
@@ -1871,14 +1886,6 @@ public fun <T> Iterable<T>.asSequence(): Sequence<T> {
return Sequence { this.iterator() }
}
/**
* Returns a list containing all elements that are instances of specified type parameter R.
*/
@kotlin.jvm.JvmVersion
public inline fun <reified R> Iterable<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {
return filterIsInstanceTo(ArrayList<R>())
}
/**
* Returns a list containing all elements that are instances of specified class.
*/
@@ -1887,15 +1894,6 @@ public fun <R> Iterable<*>.filterIsInstance(klass: Class<R>): List<R> {
return filterIsInstanceTo(ArrayList<R>(), klass)
}
/**
* Appends all elements that are instances of specified type parameter R to the given [destination].
*/
@kotlin.jvm.JvmVersion
public inline fun <reified R, C : MutableCollection<in R>> Iterable<*>.filterIsInstanceTo(destination: C): C {
for (element in this) if (element is R) destination.add(element)
return destination
}
/**
* Appends all elements that are instances of specified class to the given [destination].
*/