Desugar comparison operators as IrBinaryOperatorExpression.

They are not exactly 'compareTo' calls (although annotated with a related 'compareTo' function),
and require special treatment in BEs.
This commit is contained in:
Dmitry Petrov
2016-08-17 15:59:00 +03:00
committed by Dmitry Petrov
parent 1b018a6ead
commit db5843adc8
10 changed files with 142 additions and 32 deletions
+4
View File
@@ -0,0 +1,4 @@
fun test1(a: String, b: String) = a > b
fun test2(a: String, b: String) = a < b
fun test3(a: String, b: String) = a >= b
fun test4(a: String, b: String) = a <= b
+29
View File
@@ -0,0 +1,29 @@
IrFile /conventionComparisons.kt
IrFunction public fun test1(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=GT type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.String): kotlin.Int
GET_VAR a type=kotlin.String
GET_VAR b type=kotlin.String
IrFunction public fun test2(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=LT type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.String): kotlin.Int
GET_VAR a type=kotlin.String
GET_VAR b type=kotlin.String
IrFunction public fun test3(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=GTEQ type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.String): kotlin.Int
GET_VAR a type=kotlin.String
GET_VAR b type=kotlin.String
IrFunction public fun test4(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=LTEQ type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.String): kotlin.Int
GET_VAR a type=kotlin.String
GET_VAR b type=kotlin.String
+4
View File
@@ -0,0 +1,4 @@
fun test1(a: Int, b: Int) = a > b
fun test2(a: Int, b: Int) = a < b
fun test3(a: Int, b: Int) = a >= b
fun test4(a: Int, b: Int) = a <= b
+29
View File
@@ -0,0 +1,29 @@
IrFile /primitiveComparisons.kt
IrFunction public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=GT type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int
GET_VAR a type=kotlin.Int
GET_VAR b type=kotlin.Int
IrFunction public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=LT type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int
GET_VAR a type=kotlin.Int
GET_VAR b type=kotlin.Int
IrFunction public fun test3(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=GTEQ type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int
GET_VAR a type=kotlin.Int
GET_VAR b type=kotlin.Int
IrFunction public fun test4(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=LTEQ type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int
GET_VAR a type=kotlin.Int
GET_VAR b type=kotlin.Int