Simplify call: Fix false positive in "filter {}" detection (KT-32468)

"Simplify filter {}" conversion changes semantics when the casted type is not a subtype if an initial collection element type.
This commit limits a replacement suggestion to subtype cases.
This commit is contained in:
Yan Zhulanow
2019-07-16 16:05:29 +09:00
parent b1f132d750
commit a8d08815a6
4 changed files with 42 additions and 0 deletions
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// PROBLEM: none
interface Foo
interface Bar
fun instanceOfMarkerInterface(x: List<Foo>): List<Foo> = x.<caret>filter { it is Bar }
@@ -0,0 +1,7 @@
// WITH_RUNTIME
// PROBLEM: none
interface Foo
interface Bar : Foo
fun instanceOfMarkerInterface(x: List<Bar>): List<Bar> = x.<caret>filter { it is Foo }