Support empty if-statements
Type-check "if (...) ;" to Unit, report "implicit cast to Unit", propagate data flow info out of its condition #KT-2478 Fixed
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
fun f1(s: String?) {
|
||||
if (s!! == "");
|
||||
s : String
|
||||
}
|
||||
|
||||
fun f2(s: Number?) {
|
||||
if (s is Int);
|
||||
<!TYPE_MISMATCH!>s<!> : Int
|
||||
if (s as Int == 42);
|
||||
s : Int
|
||||
}
|
||||
|
||||
fun f3(s: Number?) {
|
||||
if (s is Int && s as Int == 42);
|
||||
<!TYPE_MISMATCH!>s<!> : Int
|
||||
}
|
||||
|
||||
fun f4(s: Int?) {
|
||||
var u = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>if (s!! == 42)<!>;
|
||||
if (u == Unit.VALUE) u = if (s == 239);
|
||||
return u
|
||||
}
|
||||
Reference in New Issue
Block a user