Retain data flow info after when-expressions

This means the subject expression and the common data flow info of all entries'
conditions
This commit is contained in:
Alexander Udalov
2012-11-14 14:47:45 +04:00
parent d0a2ba5737
commit ac7ee9d3f5
8 changed files with 86 additions and 14 deletions
@@ -0,0 +1,24 @@
fun foo(x: Number, y: Int) {
when (x) {
x as Int -> x : Int
y -> {}
else -> {}
}
<!TYPE_MISMATCH!>x<!> : Int
}
fun bar(x: Number) {
when (x) {
x as Int -> x : Int
else -> {}
}
x : Int
}
fun whenWithoutSubject(x: Number) {
when {
(x as Int) == 42 -> x : Int
else -> {}
}
x : Int
}
@@ -0,0 +1,13 @@
fun foo(x: Int, list: List<Int>?) {
when (x) {
in list!! -> list : List<Int>
else -> {}
}
}
fun whenWithoutSubject(x: Int, list: List<Int>?) {
when {
x in list!! -> list : List<Int>
else -> {}
}
}
@@ -0,0 +1,6 @@
fun foo(x: Number) {
when (x as Int) {
else -> x : Int
}
x : Int
}