FIR DFA: deprioritize branches with no reassignments in flow unions
callBothLambdas({ x = "..." }, { x is Int })
// the assignment always executes, so x is String | (String & Int);
// the latter is always a subtype of the former so it can be ignored
This commit is contained in:
+10
-2
@@ -38,8 +38,8 @@ fun test2(x: Any?) {
|
||||
var p: Any? = x
|
||||
p.<!UNRESOLVED_REFERENCE!>length<!> // Bad
|
||||
run2({ p = null; n() }, { p as String; 123 })
|
||||
p<!UNSAFE_CALL!>.<!>length // Bad: p can be null
|
||||
p?.length // OK: p is String | Nothing? = String?
|
||||
p.<!UNRESOLVED_REFERENCE!>length<!> // Bad: p is Nothing? | (String & Nothing?) = Nothing?
|
||||
p?.<!UNRESOLVED_REFERENCE!>length<!> // Technically OK because p is null, but what is "length"?
|
||||
}
|
||||
|
||||
fun test3(x: Any?) {
|
||||
@@ -63,3 +63,11 @@ fun test4(x: Any?) {
|
||||
x.x // OK: x is I1 & I2
|
||||
x.y // OK: x is I1 & I2
|
||||
}
|
||||
|
||||
fun test5(x: Any?, q: String?) {
|
||||
var p: Any? = x
|
||||
p.<!UNRESOLVED_REFERENCE!>length<!> // Bad
|
||||
run2({ p as Int; 123 }, { p = q; n() })
|
||||
p<!UNSAFE_CALL!>.<!>length // Bad: p is String? | (String? & Int) = String?
|
||||
p?.length // OK: p is String?
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user