Add intention to expand boolean expression

#KT-38597 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-05-05 14:25:13 +09:00
committed by igoriakovlev
parent f005091dfb
commit 343af60cb4
37 changed files with 257 additions and 0 deletions
@@ -7,6 +7,7 @@
// ACTION: Create property 'maximumSizeOfGroup'
// ACTION: Introduce local variable
// ACTION: Rename reference
// ACTION: Expand boolean expression to 'if else'
// ERROR: A 'return' expression required in a function with a block body ('{...}')
// ERROR: The expression cannot be a selector (occur after a dot)
// ERROR: Type inference failed: inline fun <T> Iterable<T>.firstOrNull(predicate: (T) -> Boolean): T?<br>cannot be applied to<br>receiver: Collection<List<String>> arguments: ((List<String>) -> () -> Boolean)<br>
@@ -2,5 +2,6 @@
// ACTION: Change type arguments to <*>
// ACTION: Convert to block body
// ACTION: Introduce local variable
// ACTION: Expand boolean expression to 'if else'
// ERROR: Cannot check for instance of erased type: List<Int>
fun test(a: List<Any>) = a is List<Int><caret>
@@ -2,5 +2,6 @@
// ACTION: Change type arguments to <*>
// ACTION: Convert to block body
// ACTION: Introduce local variable
// ACTION: Expand boolean expression to 'if else'
// ERROR: Cannot check for instance of erased type: List<Int>
fun <T> test(a: List<Any>) = a is List<Int><caret>
@@ -3,6 +3,7 @@
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '>'
// ACTION: Replace overloaded operator with function call
// ACTION: Expand boolean expression to 'if else'
class SafeType {
operator fun compareTo(other : SafeType) = 0
@@ -2,6 +2,7 @@
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '<'
// ACTION: Replace overloaded operator with function call
// ACTION: Expand boolean expression to 'if else'
// ERROR: Operator call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'.
class Wrapper(val x: Int)
@@ -4,6 +4,7 @@
// ACTION: Replace '&&' with '||'
// ACTION: Replace overloaded operator with function call
// ACTION: Simplify boolean expression
// ACTION: Expand boolean expression to 'if else'
// ERROR: Operator call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'.
class Wrapper(val x: Int)
@@ -3,6 +3,7 @@
// ACTION: Flip '<='
// ACTION: Enable a trailing comma by default in the formatter
// ACTION: Replace overloaded operator with function call
// ACTION: Expand boolean expression to 'if else'
// ERROR: Operator call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'.
class Wrapper(val x: Int)
@@ -2,6 +2,7 @@
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '>='
// ACTION: Replace overloaded operator with function call
// ACTION: Expand boolean expression to 'if else'
// ERROR: Operator call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'.
class Wrapper(val x: Int)
@@ -1,6 +1,7 @@
// "Change return type of called function 'AA.contains' to 'Int'" "false"
// ACTION: Change return type of enclosing function 'AAA.g' to 'Boolean'
// ACTION: Replace overloaded operator with function call
// ACTION: Expand boolean expression to 'if else'
// ERROR: Type mismatch: inferred type is Boolean but Int was expected
interface A {
operator fun contains(i: Int): Boolean