Make coercion to Unit explicit in IR.

This commit is contained in:
Dmitry Petrov
2016-09-19 15:59:49 +03:00
committed by Dmitry Petrov
parent 233a979932
commit 1c2a676cd6
22 changed files with 347 additions and 182 deletions
@@ -0,0 +1,34 @@
FILE /safeAssignment.kt
CLASS CLASS C
CONSTRUCTOR public constructor C(x: kotlin.Int)
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'constructor Any()'
INSTANCE_INITIALIZER_CALL classDescriptor='C'
PROPERTY public final var x: kotlin.Int
FIELD PROPERTY_BACKING_FIELD public final var x: kotlin.Int
EXPRESSION_BODY
GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR public final fun <get-x>(): kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='<get-x>(): Int'
GET_FIELD 'x: Int' type=kotlin.Int origin=null
receiver: THIS of 'C' type=C
FUN DEFAULT_PROPERTY_ACCESSOR public final fun <set-x>(<set-?>: kotlin.Int): kotlin.Unit
BLOCK_BODY
SET_FIELD 'x: Int' type=kotlin.Unit origin=null
receiver: THIS of 'C' type=C
value: GET_VAR 'value-parameter <set-?>: Int' type=kotlin.Int origin=null
FUN public fun test(nc: C?): kotlin.Unit
BLOCK_BODY
BLOCK type=kotlin.Unit origin=SAFE_CALL
VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: C?
GET_VAR 'value-parameter nc: C?' type=C? origin=null
WHEN type=kotlin.Unit origin=SAFE_CALL
if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null
arg1: CONST Null type=kotlin.Nothing? value='null'
then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CONST Null type=kotlin.Nothing? value='null'
else: CALL '<set-x>(Int): Unit' type=kotlin.Unit origin=EQ
$this: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null
<set-?>: CONST Int type=kotlin.Int value='42'