[FIR] Fix wrong ConstantReference for returnsNotNull in EffectExtractor

This commit is contained in:
Oleg Ivanov
2020-07-28 15:53:50 +03:00
parent f6f3787b51
commit 7da94cc299
11 changed files with 40 additions and 40 deletions

View File

@@ -58,7 +58,7 @@ class ConeEffectExtractor(
}
FirContractsDslNames.RETURNS_NOT_NULL -> {
ConeReturnsEffectDeclaration(ConeConstantReference.NULL)
ConeReturnsEffectDeclaration(ConeConstantReference.NOT_NULL)
}
FirContractsDslNames.CALLS_IN_PLACE -> {

View File

@@ -68,12 +68,12 @@ fun nested2(x: Any?) {
fun nested3(x: Any?) {
myAssert(equalsTrue(notEqualsNull(nullWhenNotString(x))))
x.<!UNRESOLVED_REFERENCE!>length<!>
x.length
}
fun branchedAndNested(x: Any?, y: Any?) {
myAssert(equalsTrue(notEqualsNull(nullWhenNotString(x))) && equalsTrue(isString(y)))
x.<!UNRESOLVED_REFERENCE!>length<!>
x.length
y.length
}
@@ -97,7 +97,7 @@ fun branchedAndNestedWithNativeOperators(x: Any?, y: Any?) {
&&
(1 == 2 || y is Int || isString(y))
)
x.<!UNRESOLVED_REFERENCE!>length<!>
x.length
y.length
y.inc()
}

View File

@@ -14,17 +14,17 @@ fun nullWhenNull(x: Int?): Int? {
fun testNullWhenNull(x: Int?) {
if (nullWhenNull(x) == null) {
x.dec()
x.<!AMBIGUITY!>dec<!>()
}
else {
x.<!AMBIGUITY!>dec<!>()
x.dec()
}
if (nullWhenNull(x) != null) {
x.<!AMBIGUITY!>dec<!>()
x.dec()
}
else {
x.dec()
x.<!AMBIGUITY!>dec<!>()
}
x.<!AMBIGUITY!>dec<!>()

View File

@@ -226,7 +226,7 @@ fun case_5(value_1: Any?) {
if (!funWithReturnsTrueAndInvertCondition(value_1 is String)) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalse(value_1 !is String)) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (funWithReturnsFalseAndInvertCondition(value_1 is String)) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (!(funWithReturnsNotNullAndInvertCondition(value_1 !is String) != null)) println(value_1.length)
if (!(funWithReturnsNotNullAndInvertCondition(value_1 !is String) != null)) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (!(funWithReturnsNullAndInvertCondition(value_1 !is String) == null)) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
@@ -320,7 +320,7 @@ fun case_13(value_1: Any?, value_2: Any?) {
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null) == null) {
println(value_1.dec())
<!AMBIGUITY!>println<!>(value_1.<!AMBIGUITY!>dec<!>())
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (funWithReturnsNullAndInvertCondition(value_1 is String && value_2 is Number) != null) {
@@ -443,7 +443,7 @@ class case_17_class {
fun case_18(value_1: Any?) {
if (!value_1.case_18_1()) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_18_2()) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_18_3() == null) println(value_1.length)
if (value_1.case_18_3() == null) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_18_4() != null) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
}
@@ -451,7 +451,7 @@ fun case_18(value_1: Any?) {
fun case_19(value_1: Number) {
when { !value_1.case_19_1() -> <!AMBIGUITY!>println<!>(value_1.inv()) }
when { value_1.case_19_2() -> <!AMBIGUITY!>println<!>(value_1.inv()) }
when { value_1.case_19_3() == null -> println(value_1.inv()) }
when { value_1.case_19_3() == null -> <!AMBIGUITY!>println<!>(value_1.inv()) }
when { value_1.case_19_4() != null -> <!AMBIGUITY!>println<!>(value_1.inv()) }
}
@@ -470,7 +470,7 @@ fun case_21(value_1: String?) {
when { !value_1.case_21_1() -> println(value_1) }
when { !value_1.case_21_2() -> println(value_1.<!INAPPLICABLE_CANDIDATE!>length<!>) }
when {
value_1.case_21_5() == null -> println(value_1.length)
value_1.case_21_5() == null -> println(value_1.<!INAPPLICABLE_CANDIDATE!>length<!>)
value_1.case_21_5() != null -> println(value_1)
}
when {

View File

@@ -113,7 +113,7 @@ fun case_9(value_1: Any?, value_2: Number?) {
println(value_2?.toByte())
}
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null) == null) {
println(value_1.dec())
<!AMBIGUITY!>println<!>(value_1.<!AMBIGUITY!>dec<!>())
println(value_2?.toByte())
}
if (funWithReturnsNull(value_1 is Float? && value_1 != null && value_2 != null) != null) {

View File

@@ -140,7 +140,7 @@ fun case_5(value_1: Any?, value_2: Any?) {
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (contracts.case_5_3(value_1, value_2) == null) {
println(value_1.length)
<!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (contracts.case_5_4(value_1, value_2) != null) {

View File

@@ -319,7 +319,7 @@ fun case_7(value_1: Any?) {
}
if (case_7_5(value_1) != null) {
value_1.<!UNRESOLVED_REFERENCE!>length<!>
if (case_7_6(value_1) != null) value_1.<!UNRESOLVED_REFERENCE!>length<!>
if (case_7_6(value_1) != null) value_1.length
}
if (case_7_7(value_1) == null) {
value_1.<!UNRESOLVED_REFERENCE!>length<!>
@@ -344,9 +344,9 @@ fun case_8(value_1: Any?) {
}
}
if (case_8_7(value_1) == null) {
value_1?.toByte()
if (case_8_8(value_1) != null) {
value_1.<!INAPPLICABLE_CANDIDATE!>toByte<!>()
value_1?.<!UNRESOLVED_REFERENCE!>toByte<!>()
if (<!INAPPLICABLE_CANDIDATE!>case_8_8<!>(value_1) != null) {
value_1.<!UNRESOLVED_REFERENCE!>toByte<!>()
if (<!INAPPLICABLE_CANDIDATE!>case_8_9<!>(value_1) != null) value_1.inv()
}
}

View File

@@ -54,8 +54,8 @@ fun case_6(value_1: Any?, value_2: Any) {
println(value_2.toByte())
}
if (funWithReturnsNotNull(value_1 is String && value_2 is Number) != null) {
<!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
<!AMBIGUITY!>println<!>(value_2.<!UNRESOLVED_REFERENCE!>toByte<!>())
println(value_1.length)
println(value_2.toByte())
}
if (funWithReturnsNull(value_1 is String && value_2 is Number) == null) {
println(value_1.length)
@@ -74,8 +74,8 @@ fun case_7(value_1: Any?, value_2: Any?) {
println(value_2.toByte())
}
if (funWithReturnsNotNullAndInvertCondition(value_1 !is String || value_2 !is Number) != null) {
<!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
<!AMBIGUITY!>println<!>(value_2.<!UNRESOLVED_REFERENCE!>toByte<!>())
println(value_1.length)
println(value_2.toByte())
}
if (funWithReturnsNullAndInvertCondition(value_1 !is String || value_2 !is Number) == null) {
println(value_1.length)
@@ -94,7 +94,7 @@ fun case_8(value_1: Any?, value_2: Any?) {
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (funWithReturnsNotNullAndInvertCondition(value_1 !is String || value_2 != null) != null) {
<!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_1.length)
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (funWithReturnsNullAndInvertCondition(value_1 !is String || value_2 != null) == null) {
@@ -114,7 +114,7 @@ fun case_9(value_1: Any?, value_2: Number?) {
println(value_2?.toByte())
}
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null) != null) {
<!AMBIGUITY!>println<!>(value_1.<!AMBIGUITY!>dec<!>())
println(value_1.dec())
println(value_2?.toByte())
}
if (funWithReturnsNull(value_1 is Float? && value_1 != null && value_2 != null) == null) {
@@ -140,9 +140,9 @@ class case_10_class {
println(o.prop_1.plus(3))
}
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null && this.prop_1 != null) != null) {
<!AMBIGUITY!>println<!>(value_1.<!AMBIGUITY!>dec<!>())
println(value_1.dec())
println(value_2?.toByte())
<!AMBIGUITY!>println<!>(o.prop_1.<!AMBIGUITY!>plus<!>(3))
println(o.prop_1.plus(3))
}
if (funWithReturnsNull(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null && this.prop_1 != null) == null) {
println(value_1.dec())

View File

@@ -119,8 +119,8 @@ fun case_4(value_1: Any?, value_2: Any?) {
println(value_2.toByte())
}
if (contracts.case_4_3(value_1, value_2) != null) {
<!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
<!AMBIGUITY!>println<!>(value_2.<!UNRESOLVED_REFERENCE!>toByte<!>())
println(value_1.length)
println(value_2.toByte())
}
if (contracts.case_4_4(value_1, value_2) == null) {
println(value_1.length)
@@ -139,7 +139,7 @@ fun case_5(value_1: Any?, value_2: Any?) {
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (contracts.case_5_3(value_1, value_2) != null) {
<!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
println(value_1.length)
<!AMBIGUITY!>println<!>(value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>())
}
if (contracts.case_5_4(value_1, value_2) == null) {

View File

@@ -185,7 +185,7 @@ fun case_4(value_1: String?, value_2: String?) {
fun case_5(value_1: Any?) {
if (value_1.case_5_1()) println(value_1.length)
if (!value_1.case_5_2()) println(value_1.length)
if (value_1.case_5_3() != null) <!AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>length<!>)
if (value_1.case_5_3() != null) println(value_1.length)
if (value_1.case_5_4() == null) println(value_1.length)
}
@@ -193,7 +193,7 @@ fun case_5(value_1: Any?) {
fun case_6(value_1: Number) {
when { value_1.case_6_1() -> println(value_1.inv()) }
when { !value_1.case_6_2() -> println(value_1.inv()) }
when { value_1.case_6_3() != null -> <!AMBIGUITY!>println<!>(value_1.inv()) }
when { value_1.case_6_3() != null -> println(value_1.inv()) }
when { value_1.case_6_4() == null -> println(value_1.inv()) }
}
@@ -207,7 +207,7 @@ fun case_7(value_1: String?) {
else println(value_1)
when (value_1.case_7_6() == null) {
true -> println(value_1)
false -> println(value_1.<!INAPPLICABLE_CANDIDATE!>length<!>)
false -> println(value_1.length)
}
if (value_1.case_7_7() != null) println(value_1)
else println(value_1.length)

View File

@@ -290,7 +290,7 @@ fun case_6(value_1: Number?, value_2: Number?) {
}
when {
case_6_5(value_2) != null -> {
value_2.<!INAPPLICABLE_CANDIDATE!>toByte<!>()
value_2.toByte()
when { case_6_6(value_2) != null -> value_2.inv() }
}
}
@@ -313,8 +313,8 @@ fun case_7(value_1: Any?, value_2: Any?) {
if (!case_7_4(value_2)) value_2.length
}
if (case_7_5(value_2) != null) {
value_2.<!UNRESOLVED_REFERENCE!>length<!>
if (case_7_6(value_2) != null) value_2.<!UNRESOLVED_REFERENCE!>length<!>
value_2.length
if (case_7_6(value_2) != null) value_2.length
}
if (case_7_7(value_2) == null) {
value_2.length
@@ -339,10 +339,10 @@ fun case_8(value_1: Any?, value_2: Any?) {
}
}
if (case_8_7(value_2) != null) {
value_2?.<!UNRESOLVED_REFERENCE!>toByte<!>()
if (<!INAPPLICABLE_CANDIDATE!>case_8_8<!>(value_2) != null) {
value_2.<!UNRESOLVED_REFERENCE!>toByte<!>()
if (<!INAPPLICABLE_CANDIDATE!>case_8_9<!>(value_2) != null) value_2.inv()
value_2?.toByte()
if (case_8_8(value_2) != null) {
value_2.toByte()
if (case_8_9(value_2) != null) value_2.inv()
}
}
if (case_8_10(value_2) == null) {