Supported "is" in when entry condition

This commit is contained in:
Valentin Kipyatkov
2016-08-25 22:59:07 +03:00
parent ecb1910bf2
commit 7687c1646b
3 changed files with 19 additions and 0 deletions
@@ -238,6 +238,12 @@ private class Processor(
return true
}
is KtWhenConditionIsPattern -> {
//TODO: smart cast is possible outside of when or inside other branches!
usePlainSearch(typeRefParent.parent as KtWhenEntry)
return true
}
is KtBinaryExpressionWithTypeRHS -> {
processSuspiciousExpression(typeRefParent)
return true
@@ -32,3 +32,15 @@ fun y(o: Any) {
val list = o as List<A>
val (x, y) = list[0]
}
fun z(o: Any) {
when (o) {
is A -> {
val (x, y) = o
}
is String -> TODO()
else -> return
}
}
@@ -10,6 +10,7 @@
[dataClass.2.kt] Value read 26 val (x, y) = o
[dataClass.2.kt] Value read 27 val (x1, y1) = A(1, "", "")
[dataClass.2.kt] Value read 33 val (x, y) = list[0]
[dataClass.2.kt] Value read 39 val (x, y) = o
[dataClass.2.kt] Value read 5 a.n
[dataClass.2.kt] Value read 8 val (x, y, z) = a
[dataClass.2.kt] Value read 9 val (x1, y1, z1) = f()