[FIR] DFA fix: imply != null after x as? NotNullType for real variables
This commit is contained in:
+3
-4
@@ -211,10 +211,9 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
if (operandVariable.isReal()) {
|
||||
flow.addImplication((expressionVariable notEq null) implies (operandVariable typeEq type))
|
||||
flow.addImplication((expressionVariable eq null) implies (operandVariable typeNotEq type))
|
||||
} else {
|
||||
if (type.nullability == ConeNullability.NOT_NULL) {
|
||||
flow.addImplication((expressionVariable notEq null) implies (operandVariable notEq null))
|
||||
}
|
||||
}
|
||||
if (type.nullability == ConeNullability.NOT_NULL) {
|
||||
flow.addImplication((expressionVariable notEq null) implies (operandVariable notEq null))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ fun test4(x: SomeClass?) {
|
||||
|
||||
fun test5(x: AnotherClass?) {
|
||||
val bar = x?.bar as? String ?: return
|
||||
x.<!INAPPLICABLE_CANDIDATE!>foo<!>
|
||||
x.foo
|
||||
}
|
||||
|
||||
fun test6(x: SomeClass?) {
|
||||
|
||||
@@ -67,7 +67,7 @@ FILE: test.kt
|
||||
}
|
||||
}
|
||||
|
||||
R|<local>/x|.<Inapplicable(WRONG_RECEIVER): [/AnotherClass.foo]>#
|
||||
R|<local>/x|.R|/AnotherClass.foo|
|
||||
}
|
||||
public final fun test6(x: R|SomeClass?|): R|kotlin/Unit| {
|
||||
lval bar: R|kotlin/String| = when (lval <elvis>: R|kotlin/String?| = (R|<local>/x|?.R|/SomeClass.bar| as? R|kotlin/String|)) {
|
||||
|
||||
Reference in New Issue
Block a user