Lift return out: do not report for zero returns

Also, do not highlight (but suggest fix) for exactly one return
Related to KT-14900
This commit is contained in:
Mikhail Glukhikh
2017-07-05 14:56:24 +03:00
parent 2deef48b84
commit 1010ecca8c
8 changed files with 72 additions and 15 deletions
@@ -1,3 +1,5 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
fun foo(): Int {
loop@ while (true) {
<caret>when (1) {
@@ -1,3 +1,5 @@
// HIGHLIGHT: GENERIC_ERROR_OR_WARNING
fun foo(): Int {
loop@ while (true) {
return when (1) {
@@ -0,0 +1,8 @@
// HIGHLIGHT: INFORMATION
fun foo(arg: Int): Int {
<caret>when (arg) {
0 -> return 0
else -> throw Exception()
}
}
@@ -0,0 +1,8 @@
// HIGHLIGHT: INFORMATION
fun foo(arg: Int): Int {
return when (arg) {
0 -> 0
else -> throw Exception()
}
}
@@ -0,0 +1,7 @@
// PROBLEM: none
fun foo(): Int {
<caret>when {
else -> throw Exception()
}
}