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
@@ -8,7 +8,7 @@ fun testBinary2() {
}
fun testElvis1() {
todo() ?: ""
todo() <!USELESS_ELVIS!>?: ""<!>
}
fun testElvis2(s: String?) {
@@ -36,4 +36,4 @@ fun returnInBinary2(): Boolean {
}
fun todo(): Nothing = throw Exception()
fun bar() {}
fun bar() {}
@@ -50,6 +50,6 @@ fun test(arr: Array<Int>) {
}
while (true) {
break ?: null
break <!USELESS_ELVIS!>?: null<!>
}
}
@@ -2,20 +2,20 @@
// See KT-8277
// NI_EXPECTED_FILE
val v = { true } ?: ( { true } ?:null!! )
val v = { true } <!USELESS_ELVIS!>?: ( { true } <!USELESS_ELVIS!>?:null!!<!> )<!>
val w = if (true) {
{ true }
}
else {
{ true } ?: null!!
{ true } <!USELESS_ELVIS!>?: null!!<!>
}
val ww = if (true) {
{ true } ?: null!!
{ true } <!USELESS_ELVIS!>?: null!!<!>
}
else if (true) {
{ true } ?: null!!
{ true } <!USELESS_ELVIS!>?: null!!<!>
}
else {
null!!
@@ -29,11 +29,11 @@ val b = null ?: ( l() ?: false)
val bb = null ?: ( l() ?: null!!)
val bbb = null ?: ( l() ?: null)
val bbb = null ?: ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>)
val bbbb = ( l() ?: null) ?: ( l() ?: null)
val bbbb = ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>) ?: ( l() <!USELESS_ELVIS_RIGHT_IS_NULL!>?: null<!>)
fun f(x : Long?): Long {
var a = x ?: (fun() {} ?: fun() {})
var a = x ?: (fun() {} <!USELESS_ELVIS!>?: fun() {}<!>)
return <!RETURN_TYPE_MISMATCH!>a<!>
}
@@ -7,6 +7,6 @@ fun foo(): String {
}
fun bar(): String {
val x = fn() ?: return ""
val y = x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() } ?: "unreachable"
val y = x<!UNNECESSARY_SAFE_CALL!>?.<!>let { throw Exception() } <!USELESS_ELVIS!>?: "unreachable"<!>
return y
}