FIR checker: report SMARTCAST_IMPOSSIBLE for local variables
This commit is contained in:
committed by
TeamCityServer
parent
092750e215
commit
0ecc752813
+38
@@ -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
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user