KT-11425: convert a.compareTo(b) to binary comparison if possible

(cherry picked from commit 7219904)
This commit is contained in:
Mikhail Glukhikh
2016-07-28 11:36:56 +03:00
committed by Mikhail Glukhikh
parent f309021c9f
commit fc13b25ca4
8 changed files with 98 additions and 13 deletions
@@ -0,0 +1,3 @@
// IS_APPLICABLE: false
val x = 2.compareTo<caret>(2) == 0
@@ -0,0 +1,3 @@
// INTENTION_TEXT: Replace with '>' operator
val x = 3.compareTo<caret>(2) > 0
@@ -0,0 +1,3 @@
// INTENTION_TEXT: Replace with '>' operator
val x = 3 > 2
@@ -0,0 +1,3 @@
// INTENTION_TEXT: Replace with '<=' operator
val x = 0 >= 4.compareTo<caret>(5)
@@ -0,0 +1,3 @@
// INTENTION_TEXT: Replace with '<=' operator
val x = 4 <= 5
@@ -0,0 +1,5 @@
// IS_APPLICABLE: false
// ERROR: Infix call corresponds to a dot-qualified call 'nullable?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'nullable?.compareTo(1)'. Use '?.'-qualified call instead
val nullable: Int? = null
val x = nullable?.compareTo<caret>(1) >= 0