Files
kotlin-fork/idea/testData/quickfix/wrapWithSafeLetCall/wrapAllNonNullablePositions5.kt.after
T
Tianyu Geng e1b542314a FIR IDE: quickfix for WrapWithSafeLetCall
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.
2021-05-20 20:33:00 +02:00

10 lines
296 B
Plaintext
Vendored

// "Wrap with '?.let { ... }' call" "true"
// SHOULD_BE_AVAILABLE_AFTER_EXECUTION
// ERROR: Type mismatch: inferred type is String? but String was expected
// WITH_RUNTIME
fun test(s: String?): String {
while (true) notNull(s?.let { notNull(it) })
}
fun notNull(name: String): String = name