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:
Tianyu Geng
2021-07-28 13:29:37 -07:00
committed by teamcityserver
parent c7272f6986
commit 263b876e6e
16 changed files with 97 additions and 98 deletions
@@ -9,7 +9,7 @@
*/
fun case_1(x: ClassWithCustomEquals) {
val y = null
if (x == y) {
if (<!SENSELESS_COMPARISON!>x == y<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
}
@@ -29,7 +29,7 @@ fun case_2(x: ClassWithCustomEquals) {
* ISSUES: KT-28243
*/
fun case_3(x: ClassWithCustomEquals, y: Nothing?) {
if (x == y) {
if (<!SENSELESS_COMPARISON!>x == y<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
}
@@ -42,7 +42,7 @@ fun case_3(x: ClassWithCustomEquals, y: Nothing?) {
*/
fun case_4(x: ClassWithCustomEquals) {
val y = null
if (y == x) {
if (<!SENSELESS_COMPARISON!>y == x<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
}
@@ -54,7 +54,7 @@ fun case_4(x: ClassWithCustomEquals) {
* ISSUES: KT-28243
*/
fun case_5(x: ClassWithCustomEquals, y: Nothing?) {
if (y == x) {
if (<!SENSELESS_COMPARISON!>y == x<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
}
@@ -67,7 +67,7 @@ fun case_5(x: ClassWithCustomEquals, y: Nothing?) {
*/
fun case_6(x: ClassWithCustomEquals) {
val y = null
if (x == y == true) {
if (<!SENSELESS_COMPARISON!>x == y<!> == true) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
}
@@ -87,7 +87,7 @@ fun case_7(x: ClassWithCustomEquals) {
* ISSUES: KT-28243
*/
fun case_8(x: ClassWithCustomEquals, y: Nothing?) {
if (!(y == x) == false) {
if (!(<!SENSELESS_COMPARISON!>y == x<!>) == false) {
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("ClassWithCustomEquals")!>x<!>.<!UNRESOLVED_REFERENCE!>inv<!>()
}