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
@@ -3233,6 +3233,21 @@ public inline fun <C : MutableCollection<in Char>> CharArray.filterIndexedTo(des
return destination
}
/**
* Returns a list containing all elements that are instances of specified type parameter R.
*/
public inline fun <reified R> Array<*>.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>> Array<*>.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].
*/
@@ -12583,14 +12598,6 @@ public fun CharArray.fill(element: Char, fromIndex: Int = 0, toIndex: Int = size
Arrays.fill(this, fromIndex, toIndex, element)
}
/**
* Returns a list containing all elements that are instances of specified type parameter R.
*/
@kotlin.jvm.JvmVersion
public inline fun <reified R> Array<*>.filterIsInstance(): List<@kotlin.internal.NoInfer R> {
return filterIsInstanceTo(ArrayList<R>())
}
/**
* Returns a list containing all elements that are instances of specified class.
*/
@@ -12599,15 +12606,6 @@ public fun <R> Array<*>.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>> Array<*>.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].
*/