KT-234 Force when() expressions to have an 'else' branch
KT-973 Unreachable code
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user