Replace with safe call: do not add redundant elvis operator
#KT-34432 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
fa0398ffd3
commit
e8effe6727
@@ -0,0 +1,7 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(list: List<String>?) {
|
||||
var s = ""
|
||||
s = list[0]<caret> ?: ""
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(list: List<String>?) {
|
||||
var s = ""
|
||||
s = list?.get(0) ?: ""
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun main() {
|
||||
var a = foo()<caret>.length ?: 0
|
||||
}
|
||||
|
||||
fun foo(): String? {
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Replace with safe (?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun main() {
|
||||
var a = foo()?.length ?: 0
|
||||
}
|
||||
|
||||
fun foo(): String? {
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with safe (this?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
var i = 0
|
||||
|
||||
fun foo(a: String?) {
|
||||
a.run {
|
||||
i = <caret>length ?: 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Replace with safe (this?.) call" "true"
|
||||
// WITH_RUNTIME
|
||||
var i = 0
|
||||
|
||||
fun foo(a: String?) {
|
||||
a.run {
|
||||
i = this?.length ?: 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user