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
@@ -153,12 +153,12 @@ fun getStringLength(obj : Any) : Char? {
}
fun toInt(i: Int?): Int = if (i != null) i else 0
fun illegalWhenBody(a: Any): Int = when(a) {
fun illegalWhenBody(a: Any): Int = <!NO_ELSE_IN_WHEN!>when<!>(a) {
is Int -> a
is String -> <!TYPE_MISMATCH!>a<!>
}
fun illegalWhenBlock(a: Any): Int {
when(a) {
<!NO_ELSE_IN_WHEN!>when<!>(a) {
is Int -> return a
is String -> return <!TYPE_MISMATCH!>a<!>
}
@@ -223,7 +223,7 @@ fun mergeAutocasts(a: Any?) {
if (a is Int || a is String) {
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
when (a) {
<!NO_ELSE_IN_WHEN!>when<!> (a) {
is String, is Any -> a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
if (a is String && a is Any) {