Introduce "Redundant '?: return null'" inspection

#KT-34819 Fixed
This commit is contained in:
Toshiaki Kameyama
2019-11-10 13:12:22 +01:00
committed by Vladimir Dolzhenko
parent 5f1cc3b152
commit 820b8c3c54
12 changed files with 162 additions and 0 deletions
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.RedundantElvisReturnNullInspection
@@ -0,0 +1,5 @@
fun foo(): Int? = null
fun test() : Int? {
return foo() <caret>?: return null
}
@@ -0,0 +1,5 @@
fun foo(): Int? = null
fun test() : Int? {
return foo()
}
@@ -0,0 +1,7 @@
// PROBLEM: none
fun foo(): Int? = null
fun test() : Int? {
val i = foo() <caret>?: return null
return 0
}
@@ -0,0 +1,6 @@
// PROBLEM: none
fun foo(): Int? = null
fun test() : Int? {
return foo() <caret>?: return 1
}
@@ -0,0 +1,6 @@
// PROBLEM: none
fun bar(): Int = 1
fun test() : Int? {
return bar() <caret>?: return null // USELESS_ELVIS
}