[FIR] Lambda reassigned arguments should not have contracts applied
When applying function contracts to arguments, make sure the argument variable hasn't been reassigned within a lambda. Contracts can only be applied to unchanged variables, otherwise outdated type statements could be added to the variable. ^KT-63151 Fixed
This commit is contained in:
+1
-1
@@ -46,6 +46,6 @@ fun safeCall() {
|
||||
fun contractFunction() {
|
||||
var x: String? = ""
|
||||
if (isNotNullAlsoCall(x) { x = null }) {
|
||||
x.length // bad (#2 == true => x#0 != null; but this is x#1 = null)
|
||||
x<!UNSAFE_CALL!>.<!>length // bad (#2 == true => x#0 != null; but this is x#1 = null)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user