'?:' (currently represented as binary expression with operator ELVIS)

This commit is contained in:
Dmitry Petrov
2016-08-17 18:04:34 +03:00
committed by Dmitry Petrov
parent 0d94c3aeb4
commit 8de21aadfa
6 changed files with 76 additions and 3 deletions
+8
View File
@@ -0,0 +1,8 @@
fun test1(a: Any?, b: Any) = a ?: b
fun test2(a: String?, b: Any) = a ?: b
fun test3(a: Any?, b: Any?): String {
if (b !is String) return ""
if (a !is String?) return ""
return a ?: b
}
+26
View File
@@ -0,0 +1,26 @@
IrFile /elvis.kt
IrFunction public fun test1(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any): kotlin.Any
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=ELVIS type=kotlin.Any related=null
GET_VAR a type=kotlin.Any?
GET_VAR b type=kotlin.Any
IrFunction public fun test2(/*0*/ a: kotlin.String?, /*1*/ b: kotlin.Any): kotlin.Any
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=true
RETURN type=<no-type>
BINARY_OP operator=ELVIS type=kotlin.Any related=null
GET_VAR a type=kotlin.String?
GET_VAR b type=kotlin.Any
IrFunction public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.String
IrExpressionBody
BLOCK type=<no-type> hasResult=false isDesugared=false
DUMMY KtIfExpression type=kotlin.Unit
DUMMY KtIfExpression type=kotlin.Unit
RETURN type=<no-type>
BINARY_OP operator=ELVIS type=kotlin.String related=null
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String?
GET_VAR a type=kotlin.Any?
TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String
GET_VAR b type=kotlin.Any?