FIR checker: report SMARTCAST_IMPOSSIBLE for local variables

This commit is contained in:
Tianyu Geng
2021-05-13 17:23:18 -07:00
committed by TeamCityServer
parent 092750e215
commit 0ecc752813
38 changed files with 792 additions and 99 deletions
@@ -0,0 +1,38 @@
fun foo(x: Int, y: Any?, z: Int) {}
fun myRun(block: () -> Unit): Any? {
return null
}
fun test_1() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
run { x = "" },
x.length // stable smartcast
)
}
}
fun test_2() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
myRun { x = "" },
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // unstable smartcast
)
}
}
fun test_3() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
{ x = "" },
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // stable smartcast
)
}
}