Inline safe call chains.
This commit is contained in:
committed by
Dmitry Petrov
parent
3f256fab67
commit
dc4bb3015c
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
fun foo(): C = this
|
||||
fun bar(): C? = this
|
||||
}
|
||||
|
||||
fun test(nc: C?) =
|
||||
nc?.foo()?.bar()?.foo()?.foo()
|
||||
@@ -0,0 +1,27 @@
|
||||
IrFile /chainOfSafeCalls.kt
|
||||
DUMMY C
|
||||
IrFunction public fun test(/*0*/ nc: C?): C?
|
||||
IrExpressionBody
|
||||
BLOCK type=<no-type> hasResult=false operator=null
|
||||
RETURN type=<no-type>
|
||||
BLOCK type=C? hasResult=true operator=SAFE_CALL
|
||||
VAR val tmp2_safe_receiver: C?
|
||||
BLOCK type=C? hasResult=true operator=SAFE_CALL
|
||||
VAR val tmp0_safe_receiver: C?
|
||||
GET_VAR nc type=C? operator=null
|
||||
WHEN type=C? operator=SAFE_CALL
|
||||
if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ
|
||||
arg0: GET_VAR tmp0_safe_receiver type=C? operator=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value='null'
|
||||
then: CONST Null type=kotlin.Nothing? value='null'
|
||||
else: CALL .bar type=C? operator=null
|
||||
$this: CALL .foo type=C operator=null
|
||||
$this: GET_VAR tmp0_safe_receiver type=C? operator=null
|
||||
WHEN type=C? operator=SAFE_CALL
|
||||
if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ
|
||||
arg0: GET_VAR tmp2_safe_receiver type=C? operator=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value='null'
|
||||
then: CONST Null type=kotlin.Nothing? value='null'
|
||||
else: CALL .foo type=C operator=null
|
||||
$this: CALL .foo type=C operator=null
|
||||
$this: GET_VAR tmp2_safe_receiver type=C? operator=null
|
||||
+5
-13
@@ -29,21 +29,13 @@ IrFile /variableAsFunctionCall.kt
|
||||
BLOCK type=<no-type> hasResult=false operator=null
|
||||
RETURN type=<no-type>
|
||||
BLOCK type=kotlin.String? hasResult=true operator=SAFE_CALL
|
||||
VAR val tmp1_safe_receiver: (() -> kotlin.String)?
|
||||
BLOCK type=(() -> kotlin.String)? hasResult=true operator=SAFE_CALL
|
||||
VAR val tmp0_safe_receiver: kotlin.String?
|
||||
GET_VAR ns type=kotlin.String? operator=null
|
||||
WHEN type=(() -> kotlin.String)? operator=SAFE_CALL
|
||||
if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ
|
||||
arg0: GET_VAR tmp0_safe_receiver type=kotlin.String? operator=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value='null'
|
||||
then: CONST Null type=kotlin.Nothing? value='null'
|
||||
else: CALL .k type=() -> kotlin.String operator=null
|
||||
$this: GET_VAR tmp0_safe_receiver type=kotlin.String? operator=null
|
||||
VAR val tmp0_safe_receiver: kotlin.String?
|
||||
GET_VAR ns type=kotlin.String? operator=null
|
||||
WHEN type=kotlin.String? operator=SAFE_CALL
|
||||
if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ
|
||||
arg0: GET_VAR tmp1_safe_receiver type=(() -> kotlin.String)? operator=null
|
||||
arg0: GET_VAR tmp0_safe_receiver type=kotlin.String? operator=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value='null'
|
||||
then: CONST Null type=kotlin.Nothing? value='null'
|
||||
else: CALL .invoke type=kotlin.String operator=null
|
||||
$this: GET_VAR tmp1_safe_receiver type=(() -> kotlin.String)? operator=null
|
||||
$this: CALL .k type=() -> kotlin.String operator=null
|
||||
$this: GET_VAR tmp0_safe_receiver type=kotlin.String? operator=null
|
||||
|
||||
Reference in New Issue
Block a user