FIR checker: warn unnecessary safe calls
This commit is contained in:
committed by
Mikhail Glukhikh
parent
2ecb6733ed
commit
5a0b75bd89
Vendored
+11
-11
@@ -27,7 +27,7 @@ fun case_3(value_1: Any?, value_2: Any?) {
|
||||
fun case_4(value_1: Any?, value_2: Number?) {
|
||||
funWithReturns(value_1 is Float? && value_1 != null && value_2 != null)
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 5
|
||||
@@ -38,7 +38,7 @@ class case_5_class {
|
||||
val o = case_5_class()
|
||||
funWithReturns(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null)
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
}
|
||||
@@ -107,19 +107,19 @@ fun case_8(value_1: Any?, value_2: Any?) {
|
||||
fun case_9(value_1: Any?, value_2: Number?) {
|
||||
if (funWithReturnsTrue(value_1 is Float? && value_1 != null && value_2 != null)) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
}
|
||||
if (!funWithReturnsFalse(value_1 is Float? && value_1 != null && value_2 != null)) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
}
|
||||
if (funWithReturnsNotNull(value_1 is Float? && value_1 != null && value_2 != null) != null) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
}
|
||||
if (funWithReturnsNull(value_1 is Float? && value_1 != null && value_2 != null) == null) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,22 +131,22 @@ class case_10_class {
|
||||
val o = case_10_class()
|
||||
if (funWithReturnsTrue(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null && this.prop_1 != null)) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
if (!funWithReturnsFalse(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null && this.prop_1 != null)) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
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) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
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())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
}
|
||||
@@ -160,5 +160,5 @@ class case_10_class {
|
||||
fun case_11(value_1: Any?, value_2: Any?, value_3: Any?) {
|
||||
funWithReturnsAndInvertCondition(value_1 !is String || value_2 !is Number || value_3 !is Any?)
|
||||
println(value_1<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length)
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
}
|
||||
|
||||
Vendored
+5
-5
@@ -103,7 +103,7 @@ class case_3_class {
|
||||
val o = case_3_class()
|
||||
contracts.case_3(value_1, value_2, o.prop_1, this.prop_1)
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
}
|
||||
@@ -155,22 +155,22 @@ class case_6_class {
|
||||
val o = case_6_class()
|
||||
if (contracts.case_6_1(value_1, value_2, o.prop_1, this.prop_1)) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
if (!contracts.case_6_2(value_1, value_2, o.prop_1, this.prop_1)) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
if (contracts.case_6_3(value_1, value_2, o.prop_1, this.prop_1) != null) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
if (contracts.case_6_4(value_1, value_2, o.prop_1, this.prop_1) == null) {
|
||||
println(value_1.dec())
|
||||
println(value_2?.toByte())
|
||||
println(value_2<!UNNECESSARY_SAFE_CALL!>?.<!>toByte())
|
||||
println(o.prop_1.plus(3))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ fun case_4(x: Any) {
|
||||
fun case_5(x: Any?) {
|
||||
if (!(x !is Nothing?)) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Nothing")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Nothing")!>x<!>?.inv()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Nothing")!>x<!><!UNNECESSARY_SAFE_CALL!>?.<!>inv()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ fun case_8(x: Any?) {
|
||||
fun case_9(x: Any?) {
|
||||
if (!!(x !is Nothing?)) else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Nothing")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Nothing")!>x<!>?.inv()
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Nothing")!>x<!><!UNNECESSARY_SAFE_CALL!>?.<!>inv()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ fun case_3(x: Class?) {
|
||||
* ISSUES: KT-30376
|
||||
*/
|
||||
fun case_4(x: Class?) {
|
||||
if (x!!?.prop_8?.prop_8?.prop_8?.prop_8 == null == true) else {
|
||||
if (x!!<!UNNECESSARY_SAFE_CALL!>?.<!>prop_8?.prop_8?.prop_8?.prop_8 == null == true) else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8<!UNSAFE_CALL!>.<!>prop_8
|
||||
@@ -68,7 +68,7 @@ fun case_4(x: Class?) {
|
||||
* ISSUES: KT-30376
|
||||
*/
|
||||
fun case_5(x: Class?) {
|
||||
if (x?.prop_8!!?.prop_8?.prop_8?.prop_8 == null == true) else {
|
||||
if (x?.prop_8!!<!UNNECESSARY_SAFE_CALL!>?.<!>prop_8?.prop_8?.prop_8 == null == true) else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8.prop_8
|
||||
@@ -83,7 +83,7 @@ fun case_5(x: Class?) {
|
||||
* ISSUES: KT-30376
|
||||
*/
|
||||
fun case_6(x: Class?) {
|
||||
if (x?.prop_8?.prop_8?.prop_8!!?.prop_8 == null == true) else {
|
||||
if (x?.prop_8?.prop_8?.prop_8!!<!UNNECESSARY_SAFE_CALL!>?.<!>prop_8 == null == true) else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Class? & Class")!>x<!>.prop_8.prop_8
|
||||
|
||||
Reference in New Issue
Block a user