Fixed some cases when smart cast problems were not detected
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>, o: Any): Int? {
|
||||
if (o is CharSequence) {
|
||||
<caret>return list
|
||||
.map { it.length + (o as String).capitalize().hashCode() }
|
||||
.map { it * o.length }
|
||||
.firstOrNull { it > 1000 }
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// WITH_RUNTIME
|
||||
// INTENTION_TEXT: "Replace with 'map{}.map{}.firstOrNull{}'"
|
||||
fun foo(list: List<String>, o: Any): Int? {
|
||||
if (o is CharSequence) {
|
||||
<caret>for (s in list) {
|
||||
val a = s.length + (o as String).capitalize().hashCode()
|
||||
val x = a * o.length
|
||||
if (x > 1000) return x
|
||||
}
|
||||
return null
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(list: List<Any>): String? {
|
||||
<caret>for (o in list) {
|
||||
if (bar(o as String)) {
|
||||
return o
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
fun bar(s: String): Boolean = true
|
||||
@@ -0,0 +1,14 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(list: List<Any>): String? {
|
||||
var v: String? = null
|
||||
<caret>for (o in list) {
|
||||
if (bar(o as String)) {
|
||||
v = o
|
||||
break
|
||||
}
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
fun bar(s: String): Boolean = true
|
||||
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun foo(list: List<Any>, target: MutableCollection<String>) {
|
||||
<caret>for (o in list) {
|
||||
if (bar(o as String)) {
|
||||
target.add(o)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(s: String): Boolean = true
|
||||
Reference in New Issue
Block a user