FIR checker: warn useless elvis

This commit is contained in:
Jinseong Jeon
2021-04-19 10:12:20 -07:00
committed by TeamCityServer
parent b2005302dc
commit 24d792fb49
44 changed files with 171 additions and 109 deletions
@@ -4,7 +4,7 @@
// TESTCASE NUMBER: 1
fun case_1(x: Int?) {
if ((x is Int) ?: (x is Int)) {
if ((x is Int) <!USELESS_ELVIS!>?: (x is Int)<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>inv()
}
@@ -4,7 +4,7 @@
// TESTCASE NUMBER: 1
fun case_1(x: Int?) {
if ((x is Int) ?: (x is Int)) {
if ((x is Int) <!USELESS_ELVIS!>?: (x is Int)<!>) {
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!><!UNSAFE_CALL!>.<!>inv()
}
@@ -6,7 +6,7 @@
fun <T: Any, K: Any> case_1(x: T?, y: K?) {
x as T
y as K
val z = <!DEBUG_INFO_EXPRESSION_TYPE("T? & T?!!")!>x<!> ?: <!DEBUG_INFO_EXPRESSION_TYPE("K? & K?!!")!>y<!>
val z = <!DEBUG_INFO_EXPRESSION_TYPE("T? & T?!!")!>x<!> <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("K? & K?!!")!>y<!><!>
<!DEBUG_INFO_EXPRESSION_TYPE("T? & T?!!")!>x<!>.equals(10)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>z<!>
@@ -34,7 +34,7 @@ fun case_2(x: Any?) {
*/
fun case_3(x: Any?) {
while (true) {
x ?: return ?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>
x ?: return <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!><!>
}
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
@@ -137,7 +137,7 @@ fun case_10(x: Any?, z: Any, b: Boolean?) {
// TESTCASE NUMBER: 11
fun case_11(x: Any?, z: Any, b: Boolean?) {
while (true) {
var y = x ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break ?: break::class
var y = x ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break <!USELESS_ELVIS!>?: break::class<!>
z !== y && if (b == true) return else if (b === false) null!!else throw Exception()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any? & kotlin.Any")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>
@@ -148,7 +148,7 @@ fun case_11(x: Any?, z: Any, b: Boolean?) {
// TESTCASE NUMBER: 12
fun case_12(x: Any?, z: Any, b: Boolean?) {
while (true) {
var y = select(x) ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break ?: break::class
var y = select(x) ?: if (b == true) continue<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!> else if (!(b != false)) return else break <!USELESS_ELVIS!>?: break::class<!>
select(z) !== y && if (b == true) return else if (b === false) null!!else throw Exception()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any?")!>x<!>
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Any")!>y<!>
@@ -34,7 +34,7 @@ fun case_2(a: Any?) {
*/
fun case_3(x: Int?) {
while (true) {
x ?: return ?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!>
x ?: return <!USELESS_ELVIS!>?: <!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>x<!><!>
}
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>x<!>
@@ -37,7 +37,7 @@ fun case_2(): Int {
var c: Int? = null
if (c == null || 0 < c) c = 0
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int? & kotlin.Int")!>c<!>
return c ?: 0
return c <!USELESS_ELVIS!>?: 0<!>
}
var c: Int = 0