Add quick-fix "Replace with safe call & elvis" #KT-17815 Fixed

This commit is contained in:
Toshiaki Kameyama
2017-06-23 11:53:08 +03:00
committed by Mikhail Glukhikh
parent c2707bb81b
commit af53a0ecd5
24 changed files with 309 additions and 28 deletions
@@ -0,0 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun foo(array: Array<String>?) {
var s = ""
s = array[0]<caret>
}
@@ -0,0 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun foo(array: Array<String>?) {
var s = ""
s = array?.get(0) ?: <caret>
}
@@ -0,0 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun foo(bar: Int?) {
var i: Int = 1
i = bar +<caret> 1
}
@@ -0,0 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun foo(bar: Int?) {
var i: Int = 1
i = bar?.plus(1) ?: <caret>
}
@@ -0,0 +1,8 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun bar() {
val fff: (() -> Int)? = { 1 }
var i: Int = 1
i = fff<caret>()
}
@@ -0,0 +1,8 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun bar() {
val fff: (() -> Int)? = { 1 }
var i: Int = 1
i = fff?.invoke() ?: <caret>
}
@@ -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) ?: <caret>
}