do...while (true) is now considered infinite loop in CFA #KT-3896 Fixed

Also #KT-3883 Fixed
Also #KT-4986 Fixed
This commit is contained in:
Mikhail Glukhikh
2016-03-11 19:27:08 +03:00
parent 4cf3ec3df2
commit 569a5888ff
11 changed files with 221 additions and 10 deletions
@@ -0,0 +1,55 @@
fun unreachable() {}
fun a() {
do {
} while (true)
<!UNREACHABLE_CODE!>unreachable()<!>
}
fun b() {
while (true) {
}
<!UNREACHABLE_CODE!>unreachable()<!>
}
fun c() {
do {} while (1 == 1)
}
fun d() {
while (2 == 2) {}
}
fun use(arg: Any) = arg
fun f(cond: Boolean) {
val bar: Any
do {
if (cond) {
bar = "value"
break
}
} while (true)
use(bar) // should work
val foo: Any
while (true) {
if (cond) {
foo = "value"
break
}
}
use(foo) // should work
}
fun g(): Int {
do {
if (true) return 12
} while (true)
} // should work
fun h(): Int {
while (true) {
if (true) return 12
}
} // should work