Refactoring.

'if' expressions (represented as 'when' without subject).
This commit is contained in:
Dmitry Petrov
2016-08-19 10:55:14 +03:00
committed by Dmitry Petrov
parent 1ddf889d8a
commit 5709826096
28 changed files with 362 additions and 91 deletions
+8 -2
View File
@@ -16,8 +16,14 @@ IrFile /elvis.kt
IrFunction public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.String
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
DUMMY KtIfExpression type=kotlin.Unit
DUMMY KtIfExpression type=kotlin.Unit
WHEN subject=null type=kotlin.Unit
if: DUMMY KtIsExpression type=kotlin.Boolean
then: RETURN type=<no-type>
LITERAL String type=kotlin.String value=''
WHEN subject=null type=kotlin.Unit
if: DUMMY KtIsExpression type=kotlin.Boolean
then: RETURN type=<no-type>
LITERAL String type=kotlin.String value=''
RETURN type=<no-type>
BINARY_OP operator=ELVIS type=kotlin.String related=null
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String?
+4
View File
@@ -0,0 +1,4 @@
fun test(i: Int) =
if (i > 0) 1
else if (i < 0) -1
else 0
+15
View File
@@ -0,0 +1,15 @@
IrFile /ifElseIf.kt
IrFunction public fun test(/*0*/ i: kotlin.Int): kotlin.Int
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
RETURN type=<no-type>
WHEN subject=null type=kotlin.Int
if: BINARY_OP operator=GT type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int
GET_VAR i type=kotlin.Int operator=null
LITERAL Int type=kotlin.Int value='0'
then: LITERAL Int type=kotlin.Int value='1'
if: BINARY_OP operator=LT type=kotlin.Boolean related=public open override /*1*/ fun compareTo(/*0*/ other: kotlin.Int): kotlin.Int
GET_VAR i type=kotlin.Int operator=null
LITERAL Int type=kotlin.Int value='0'
then: DUMMY MINUS type=kotlin.Int
else: LITERAL Int type=kotlin.Int value='0'
+11 -3
View File
@@ -18,7 +18,9 @@ IrFile /smartCasts.kt
IrFunction public fun test1(/*0*/ x: kotlin.Any): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
DUMMY KtIfExpression type=kotlin.Unit
WHEN subject=null type=kotlin.Unit
if: DUMMY KtIsExpression type=kotlin.Boolean
then: RETURN type=<no-type>
CALL .println type=kotlin.Unit operator=null
message: GET_PROPERTY .length type=kotlin.Int operator=null
$this: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String
@@ -37,7 +39,10 @@ IrFile /smartCasts.kt
IrFunction public fun test2(/*0*/ x: kotlin.Any): kotlin.String
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
DUMMY KtIfExpression type=kotlin.Unit
WHEN subject=null type=kotlin.Unit
if: DUMMY KtIsExpression type=kotlin.Boolean
then: RETURN type=<no-type>
LITERAL String type=kotlin.String value=''
RETURN type=<no-type>
CALL .overloaded type=kotlin.String operator=null
s: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String
@@ -45,7 +50,10 @@ IrFile /smartCasts.kt
IrFunction public fun test3(/*0*/ x: kotlin.Any): kotlin.String
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
DUMMY KtIfExpression type=kotlin.Unit
WHEN subject=null type=kotlin.Unit
if: DUMMY KtIsExpression type=kotlin.Boolean
then: RETURN type=<no-type>
LITERAL String type=kotlin.String value=''
RETURN type=<no-type>
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String
GET_VAR x type=kotlin.Any operator=null
@@ -14,7 +14,9 @@ IrFile /smartCastsWithDestructuring.kt
IrFunction public fun test(/*0*/ x: I1): kotlin.Unit
IrExpressionBody
BLOCK type=<no-type> hasResult=false operator=null
DUMMY KtIfExpression type=kotlin.Unit
WHEN subject=null type=kotlin.Unit
if: DUMMY KtIsExpression type=kotlin.Boolean
then: RETURN type=<no-type>
BLOCK type=<no-type> hasResult=false operator=SYNTHETIC_BLOCK
VAR val tmp0: I1
GET_VAR x type=I1 operator=null