Do not suggest "Replace infix with safe call" inside conditions or binary / unary expressions #KT-13328 Fixed

This commit is contained in:
Mikhail Glukhikh
2016-08-11 15:39:55 +03:00
parent 42969271ab
commit b53cb91e88
8 changed files with 84 additions and 3 deletions
@@ -2,6 +2,6 @@
// ERROR: Infix call corresponds to a dot-qualified call 'value?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'value?.compareTo(1)'. Use '?.'-qualified call instead
var foo: Int? = null
set(value) {
if(value <caret>< 1) {
if((value <caret>< 1) ?: false) {
}
}
@@ -2,6 +2,6 @@
// ERROR: Infix call corresponds to a dot-qualified call 'value?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'value?.compareTo(1)'. Use '?.'-qualified call instead
var foo: Int? = null
set(value) {
if(value?.compareTo(1) < 0) {
if((value?.compareTo(1) < 0) ?: false) {
}
}
@@ -0,0 +1,11 @@
// "Replace with safe (?.) call" "false"
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '<'
// ACTION: Replace overloaded operator with function call
// ERROR: Infix call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'. Use '?.'-qualified call instead
class Wrapper(val x: Int)
fun test(w: Wrapper?) {
if (w?.x <caret>< 42) {}
}
@@ -0,0 +1,12 @@
// "Replace with safe (?.) call" "false"
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '>'
// ACTION: Replace overloaded operator with function call
// ACTION: Simplify boolean expression
// ERROR: Infix call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'. Use '?.'-qualified call instead
class Wrapper(val x: Int)
fun test(w: Wrapper?) {
val t = 1 < 2 && w?.x <caret>> 42
}
@@ -0,0 +1,13 @@
// "Replace with safe (?.) call" "false"
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '<='
// ACTION: Replace overloaded operator with function call
// ERROR: Infix call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'. Use '?.'-qualified call instead
class Wrapper(val x: Int)
fun test(w: Wrapper?) {
when {
w?.x <caret><= 42 -> {}
}
}
@@ -0,0 +1,11 @@
// "Replace with safe (?.) call" "false"
// ACTION: Add non-null asserted (!!) call
// ACTION: Flip '>='
// ACTION: Replace overloaded operator with function call
// ERROR: Infix call corresponds to a dot-qualified call 'w?.x.compareTo(42)' which is not allowed on a nullable receiver 'w?.x'. Use '?.'-qualified call instead
class Wrapper(val x: Int)
fun test(w: Wrapper?) {
while (w?.x <caret>>= 42) {}
}