Useless call on collection: propose 'Replace with toList()' instead of 'Remove useless call' if receiver is array type

#KT-38961 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-05-18 22:04:26 +09:00
committed by Nikita Bobko
parent 994897cee9
commit 081d6c1dff
11 changed files with 90 additions and 1 deletions
@@ -0,0 +1,3 @@
// WITH_RUNTIME
val x: List<String> = arrayOf("1").<caret>filterIsInstance<String>()
@@ -0,0 +1,3 @@
// WITH_RUNTIME
val x: List<String> = arrayOf("1").toList()
@@ -0,0 +1,3 @@
// WITH_RUNTIME
val x: List<String> = arrayOf("1").<caret>filterNotNull()
@@ -0,0 +1,3 @@
// WITH_RUNTIME
val x: List<String> = arrayOf("1").toList()
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(iterable: Iterable<Int>): List<Int> {
return iterable.<caret>filterNotNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(iterable: Iterable<Int>): List<Int> {
return iterable.toList()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return setOf(1).<caret>filterNotNull()
}
@@ -0,0 +1,5 @@
// WITH_RUNTIME
fun test(): List<Int> {
return setOf(1).toList()
}