FIR: extends scope of SENSELESS_COMPARISON
FE1.0 only reports SENSELESS_COMPARISON if one of the operand is `null`. This change makes FIR reports also in case one of the operand has type `Nothing?`. In addition, fix handling of type alias in ConeTypeContext#isNullableType
This commit is contained in:
committed by
teamcityserver
parent
c7272f6986
commit
263b876e6e
@@ -192,9 +192,9 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) {
|
||||
|
||||
} else {
|
||||
if (<!SENSELESS_COMPARISON!>x != null<!>) {
|
||||
if (<!SENSELESS_COMPARISON!>y != null<!> || <!SENSELESS_COMPARISON!>y != null<!>) {
|
||||
if (y != null || <!SENSELESS_COMPARISON!>y != null<!>) {
|
||||
if (<!SENSELESS_COMPARISON!>stringProperty == null<!> && <!SENSELESS_COMPARISON!>nullableNothingProperty == null<!>) {
|
||||
if (<!SENSELESS_COMPARISON!>t != null<!> || <!SENSELESS_COMPARISON!>t != null<!>) {
|
||||
if (t != null || <!SENSELESS_COMPARISON!>t != null<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>.equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString? & kotlin.Any & TypealiasNullableString")!>x<!>.propT
|
||||
@@ -213,8 +213,8 @@ fun case_11(x: TypealiasNullableString?, y: TypealiasNullableString) {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 12
|
||||
fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (<!SENSELESS_COMPARISON!>x == null<!>) "1"
|
||||
else if (<!SENSELESS_COMPARISON!>y === null<!> || <!SENSELESS_COMPARISON!>y === null<!>) {
|
||||
fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (x == null) "1"
|
||||
else if (y === null || <!SENSELESS_COMPARISON!>y === null<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.propT
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasNullableString & kotlin.Any & TypealiasNullableString")!>x<!>.propAny
|
||||
@@ -229,7 +229,7 @@ fun case_12(x: TypealiasNullableString, y: TypealiasNullableString) = <!DEBUG_IN
|
||||
|
||||
// TESTCASE NUMBER: 13
|
||||
fun case_13(x: orherpackage.EmptyClass13?, y: Nothing?) =
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("orherpackage.EmptyClass13")!>if (x == null || x === y) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("orherpackage.EmptyClass13")!>if (x == null || <!SENSELESS_COMPARISON!>x === y<!>) {
|
||||
throw Exception()
|
||||
} else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("orherpackage.EmptyClass13? & orherpackage.EmptyClass13")!>x<!>.equals(null)
|
||||
@@ -247,7 +247,7 @@ fun case_13(x: orherpackage.EmptyClass13?, y: Nothing?) =
|
||||
// TESTCASE NUMBER: 14
|
||||
fun case_14() {
|
||||
val a = Class()
|
||||
if (a.prop_6 != a.prop_7) {
|
||||
if (<!SENSELESS_COMPARISON!>a.prop_6 != a.prop_7<!>) {
|
||||
a.prop_6
|
||||
a.prop_6.equals(null)
|
||||
a.prop_6.propT
|
||||
@@ -264,7 +264,7 @@ fun case_14() {
|
||||
// TESTCASE NUMBER: 15
|
||||
fun case_15(x: TypealiasString?) {
|
||||
var y = null
|
||||
val t = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (x === null || x == y && x === y) "" else {
|
||||
val t = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>if (x === null || <!SENSELESS_COMPARISON!>x == y<!> && x === y) "" else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString? & TypealiasString")!>x<!>.equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString? & TypealiasString")!>x<!>.propT
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("TypealiasString? & TypealiasString")!>x<!>.propAny
|
||||
@@ -290,7 +290,7 @@ fun case_16() {
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 17
|
||||
val case_17 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (nullableIntProperty == null || nullableNothingProperty === nullableIntProperty) 0 else {
|
||||
val case_17 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (nullableIntProperty == null || <!SENSELESS_COMPARISON!>nullableNothingProperty === nullableIntProperty<!>) 0 else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>nullableIntProperty<!>.equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>nullableIntProperty<!>.propT
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>nullableIntProperty<!>.propAny
|
||||
@@ -309,7 +309,7 @@ val case_17 = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>if (nullableIntPropert
|
||||
* ISSUES: KT-28328
|
||||
*/
|
||||
fun case_18(a: DeepObject.A.B.C.D.E.F.G.J?, b: Nothing?) {
|
||||
if (a != null || b !== a || false) {
|
||||
if (a != null || <!SENSELESS_COMPARISON!>b !== a<!> || false) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J?")!>a<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J?")!>a<!><!UNSAFE_CALL!>.<!>equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("DeepObject.A.B.C.D.E.F.G.J?")!>a<!>.propT
|
||||
@@ -371,7 +371,7 @@ fun case_20(b: Boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
if (a.B19.C19.D19 !== null || a.y != a.B19.C19.D19) {
|
||||
if (a.B19.C19.D19 !== null || <!SENSELESS_COMPARISON!>a.y != a.B19.C19.D19<!>) {
|
||||
a.B19.C19.D19
|
||||
a.B19.C19.D19<!UNSAFE_CALL!>.<!>equals(null)
|
||||
a.B19.C19.D19.propT
|
||||
@@ -388,7 +388,7 @@ fun case_20(b: Boolean) {
|
||||
// TESTCASE NUMBER: 21
|
||||
fun case_21() {
|
||||
val y = null
|
||||
if (EnumClassWithNullableProperty.A.prop_1 !== null && y != EnumClassWithNullableProperty.A.prop_1) {
|
||||
if (EnumClassWithNullableProperty.A.prop_1 !== null && <!SENSELESS_COMPARISON!>y != EnumClassWithNullableProperty.A.prop_1<!>) {
|
||||
EnumClassWithNullableProperty.A.prop_1
|
||||
EnumClassWithNullableProperty.A.prop_1.equals(null)
|
||||
EnumClassWithNullableProperty.A.prop_1.propT
|
||||
@@ -405,7 +405,7 @@ fun case_21() {
|
||||
// TESTCASE NUMBER: 22
|
||||
fun case_22(a: (() -> Unit)?) {
|
||||
var y = null
|
||||
if (a != null || y != a) {
|
||||
if (a != null || <!SENSELESS_COMPARISON!>y != a<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Unit")!><!UNSAFE_IMPLICIT_INVOKE_CALL!>a<!>()<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function0<kotlin.Unit>?")!>a<!><!UNSAFE_CALL!>.<!>equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Function0<kotlin.Unit>?")!>a<!>.propT
|
||||
@@ -423,7 +423,7 @@ fun case_22(a: (() -> Unit)?) {
|
||||
fun case_23(a: ((Float) -> Int?)?, b: Float?, c: Nothing?) {
|
||||
if (a != null && b !== null || a != c && b !== c) {
|
||||
val x = <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!><!UNSAFE_IMPLICIT_INVOKE_CALL!>a<!>(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Float?")!>b<!>)<!>
|
||||
if (x != null || c !== x) {
|
||||
if (x != null || <!SENSELESS_COMPARISON!>c !== x<!>) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>equals(null)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>.propT
|
||||
@@ -473,7 +473,7 @@ fun case_25(b: Boolean) {
|
||||
|
||||
val y = if (b) x else null
|
||||
|
||||
if (y !== null || x()!!.b != y) {
|
||||
if (y !== null || <!SENSELESS_COMPARISON!>x()!!.b != y<!>) {
|
||||
if (x()!!.b != y) {
|
||||
val z = <!DEBUG_INFO_EXPRESSION_TYPE("<anonymous>?")!><!UNSAFE_IMPLICIT_INVOKE_CALL!>y<!>()<!>
|
||||
|
||||
@@ -516,7 +516,7 @@ fun case_26(a: ((Float) -> Int?)?, b: Float?) {
|
||||
|
||||
// TESTCASE NUMBER: 27
|
||||
fun case_27(y: Nothing?) {
|
||||
if (Object.prop_1 == null == true == true == true == true == true == true == true == true == true == true == true == true == true == true || y == Object.prop_1 == true == true == true == false == false)
|
||||
if (Object.prop_1 == null == true == true == true == true == true == true == true == true == true == true == true == true == true == true || <!SENSELESS_COMPARISON!>y == Object.prop_1<!> == true == true == true == false == false)
|
||||
else {
|
||||
Object.prop_1
|
||||
Object.prop_1.equals(null)
|
||||
|
||||
Reference in New Issue
Block a user