FIR CFG: check lambda concurrency by data flow, not control flow
var p: String? = something
if (p != null) {
foo(
run { p = null; n() },
// This lambda executes strictly after the one above by CFG,
// but data flow for type inference comes from before the call
// so p would get smartcasted if not forbidden.
run { p.length; 123 }
)
}
This commit is contained in:
+11
@@ -23,6 +23,17 @@ fun test1(x: String?) {
|
||||
}
|
||||
}
|
||||
|
||||
fun test1_tail(x: String?) {
|
||||
var p = x
|
||||
if (p != null) {
|
||||
run2({ p = null; n() }) {
|
||||
<!SMARTCAST_IMPOSSIBLE!>p<!>.length // Bad: may or may not not be called first
|
||||
123
|
||||
}
|
||||
p<!UNSAFE_CALL!>.<!>length // Bad: p = null
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(x: Any?) {
|
||||
var p: Any? = x
|
||||
p.<!UNRESOLVED_REFERENCE!>length<!> // Bad
|
||||
|
||||
Reference in New Issue
Block a user