e1b542314a
There is some behavior change regarding the new WrapWithSafeLetCall quickfix
1. it now works correctly on binary expressions by wrapping it with `()`
2. it now looks for a nullable position upward and do the modification there,
if possible. For example, consider the following code
```
fun bar(s: String): String = s
fun test(s: String?) {
bar(bar(bar(<caret>s)))
}
```
After applying this fix, FE1.0 yields
```
bar(bar(s?.let { bar(it) }))
```
while the new implementation yields
```
s?.let { bar(bar(bar(it))) }
```
This behavior aligns with FE1.0 if `bar` accepts nullable values.
22 lines
626 B
Kotlin
Vendored
22 lines
626 B
Kotlin
Vendored
// "Wrap with '?.let { ... }' call" "false"
|
|
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
|
|
// ACTION: Add 'a =' to argument
|
|
// ACTION: Add non-null asserted (!!) call
|
|
// ACTION: Flip '+'
|
|
// ACTION: Introduce local variable
|
|
// ACTION: Replace overloaded operator with function call
|
|
// ACTION: Replace with safe (?.) call
|
|
// ACTION: Surround with null check
|
|
// ERROR: Operator call corresponds to a dot-qualified call 'a1.plus(a2)' which is not allowed on a nullable receiver 'a1'.
|
|
// WITH_RUNTIME
|
|
|
|
interface A {
|
|
operator fun plus(a: A): A = this
|
|
}
|
|
|
|
fun test(a1: A?, a2: A) {
|
|
notNull(a1 <caret>+ a2)
|
|
}
|
|
|
|
fun notNull(a: A): A = a
|