Surround with null check for unsafe things: find first parent statement to surround (which is not used as expression) #KT-13958 Fixed
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
// "Surround with null check" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foz(arg: String?) {
|
||||
if (arg<caret>.isNotEmpty()) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// "Surround with null check" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foz(arg: String?) {
|
||||
if (arg != null) {
|
||||
if (arg.isNotEmpty()) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,5 @@
|
||||
// "Surround with null check" "false"
|
||||
// "Surround with null check" "true"
|
||||
// WITH_RUNTIME
|
||||
// ACTION: Add 'block =' to argument
|
||||
// ACTION: Add non-null asserted (!!) call
|
||||
// ACTION: Convert to block body
|
||||
// ACTION: Introduce local variable
|
||||
// ACTION: Replace with safe (?.) call
|
||||
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type Int?
|
||||
|
||||
fun foo(arg: Int?) {
|
||||
run(fun() = arg<caret>.hashCode())
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Surround with null check" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun foo(arg: Int?) {
|
||||
if (arg != null) {
|
||||
run(fun() = arg.hashCode())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user