FIR checker: warn useless elvis
This commit is contained in:
committed by
TeamCityServer
parent
b2005302dc
commit
24d792fb49
Vendored
+2
-2
@@ -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() {}
|
||||
|
||||
Vendored
+1
-1
@@ -50,6 +50,6 @@ fun test(arr: Array<Int>) {
|
||||
}
|
||||
|
||||
while (true) {
|
||||
break ?: null
|
||||
break <!USELESS_ELVIS!>?: null<!>
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -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<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user