More correct checking of smart cast preserving

This commit is contained in:
Valentin Kipyatkov
2016-08-12 21:53:56 +03:00
parent bfed954e85
commit 054558ad95
5 changed files with 40 additions and 19 deletions
@@ -0,0 +1,13 @@
// WITH_RUNTIME
// INTENTION_TEXT: "Replace with 'map{}.map{}.firstOrNull{}'"
// INTENTION_TEXT_2: "Replace with 'asSequence().map{}.map{}.firstOrNull{}'"
fun foo(list: List<String>, o: Any): Int? {
if (o is CharSequence) {
<caret>return list
.asSequence()
.map { it.length + (o as String).capitalize().hashCode() }
.map { it * o.length }
.firstOrNull { it > 1000 }
}
return 0
}