[NI] Fix smart cast for expression with captured input type.

This commit is contained in:
Stanislav Erokhin
2017-04-13 14:23:49 +03:00
parent 73cc1fdd9c
commit 397103f9d0
4 changed files with 21 additions and 2 deletions
@@ -0,0 +1,8 @@
/*
Here element has type Captured(*) because of resolution for `iterator()` on this.
and where we resolve `destination.add(element)` we approximate element to `Any` with smart cast to `R`.
*/
inline fun <reified R, C : MutableCollection<in R>> Array<*>.filterIsInstanceTo(destination: C): C {
for (element in this) if (element is R) destination.add(<!DEBUG_INFO_SMARTCAST!>element<!>)
return destination
}
@@ -0,0 +1,3 @@
package
public inline fun </*0*/ reified R, /*1*/ C : kotlin.collections.MutableCollection<in R>> kotlin.Array<*>.filterIsInstanceTo(/*0*/ destination: C): C