KT-234 Force when() expressions to have an 'else' branch

KT-973 Unreachable code
This commit is contained in:
svtk
2012-01-18 13:31:42 +04:00
parent 94e3cc9976
commit becd713111
23 changed files with 175 additions and 50 deletions
+6 -7
View File
@@ -4,7 +4,6 @@ fun foo() : Int {
val s = ""
val x = 1
when (x) {
is * -> 1
is <!INCOMPATIBLE_TYPES!>String<!> -> 1
!is Int -> 1
is Any? -> 1
@@ -16,7 +15,7 @@ fun foo() : Int {
// Commented for KT-621 .<!!UNRESOLVED_REFERENCE!>a<!!> => 1
// Commented for KT-621 .equals(1).<!!UNRESOLVED_REFERENCE!>a<!!> => 1
// Commented for KT-621 <!UNNECESSARY_SAFE_CALL!!>?.<!!>equals(1) => 1
else -> 1
is * -> 1
}
// Commented for KT-621
@@ -34,7 +33,7 @@ fun test() {
val x = 1;
val s = "";
when (x) {
<!NO_ELSE_IN_WHEN!>when<!> (x) {
<!INCOMPATIBLE_TYPES!>s<!> -> 1
is <!INCOMPATIBLE_TYPES!>""<!> -> 1
x -> 1
@@ -44,7 +43,7 @@ fun test() {
val z = #(1, 1)
when (z) {
<!NO_ELSE_IN_WHEN!>when<!> (z) {
is #(*, *) -> 1
is #(*, 1) -> 1
is #(1, 1) -> 1
@@ -55,8 +54,8 @@ fun test() {
}
when (z) {
<!ELSE_MISPLACED_IN_WHEN!>else -> 1<!>
#(1, 1) -> 2
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> 1
<!UNREACHABLE_CODE!>#(1, 1) -> 2<!>
}
when (z) {
@@ -64,4 +63,4 @@ fun test() {
}
}
val #(Int, Int).boo : #(Int, Int, Int) = #(1, 1, 1)
val #(Int, Int).boo : #(Int, Int, Int) = #(1, 1, 1)