QuickFix for ELSE_MISPLACED_IN_WHEN.

This commit is contained in:
Michał Sapalski
2013-01-19 16:24:51 -08:00
committed by Evgeny Gerashchenko
parent 8d71840255
commit e9613b95ac
7 changed files with 151 additions and 0 deletions
@@ -0,0 +1,9 @@
// "Move else branch to the end" "true"
fun test() {
val a = 12
when (a) {
1 -> { /* some code */ }
2 -> { /* some more code */ }
el<caret>se -> { /* other code */ }
}
}
@@ -0,0 +1,16 @@
// "Move else branch to the end" "false"
// ERROR: 'else' entry must be the last one in a when-expression
// ERROR: 'else' entry must be the last one in a when-expression
// ERROR: Unreachable code
// ERROR: Unreachable code
package foo
fun foo() {
var i = 2
when (i) {
1, 2 -> { /* some code */ }
el<caret>se -> { /* first else branch */ }
else -> { /* second else branch */ }
3 -> { /* some other code */ }
}
}
@@ -0,0 +1,9 @@
// "Move else branch to the end" "true"
fun test() {
val a = 12
when (a) {
1 -> { /* some code */ }
el<caret>se -> { /* other code */ }
2 -> { /* some more code */ }
}
}
@@ -0,0 +1,16 @@
// "Move else branch to the end" "false"
// ERROR: 'else' entry must be the last one in a when-expression
// ERROR: 'else' entry must be the last one in a when-expression
// ERROR: Unreachable code
// ERROR: Unreachable code
package foo
fun foo() {
var i = 2
when (i) {
1, 2 -> { /* some code */ }
el<caret>se -> { /* first else branch */ }
else -> { /* second else branch */ }
3 -> { /* some other code */ }
}
}