Data flow info: correct disjunction of a type with Nothing: Type U Nothing = Type #KT-9578 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-01-18 14:59:24 +03:00
parent 5d3186ac49
commit 9360bd49a6
6 changed files with 61 additions and 3 deletions
@@ -0,0 +1,21 @@
fun foo(s: Any): String {
val x = when (s) {
is String -> s
is Int -> "$s"
else -> return ""
}
val y: String = <!DEBUG_INFO_SMARTCAST!>x<!> // should be Ok
return y
}
fun bar(s: Any): String {
val x = when (s) {
is String -> s <!USELESS_CAST!>as String<!> // meaningless
is Int -> "$s"
else -> return ""
}
val y: String = x // no error
return y
}
@@ -0,0 +1,4 @@
package
public fun bar(/*0*/ s: kotlin.Any): kotlin.String
public fun foo(/*0*/ s: kotlin.Any): kotlin.String