From 66bd8dccfa1d51695908ae63f2ec91461a5c6f47 Mon Sep 17 00:00:00 2001 From: "Denis.Zharkov" Date: Mon, 28 Mar 2022 18:47:29 +0300 Subject: [PATCH] FIR: Unignore all Fir2IrText tests on context receivers --- .../arrayAccessCompositeOperators.fir.ir.txt | 213 ++++++++++++ .../arrayAccessCompositeOperators.fir.kt.txt | 85 +++++ .../arrayAccessCompositeOperators.kt | 1 - .../arrayAccessOperators.fir.ir.txt | 185 ++++++++++ .../arrayAccessOperators.fir.kt.txt | 78 +++++ .../contextReceivers/arrayAccessOperators.kt | 3 +- .../contextReceivers/class.fir.ir.txt | 79 +++++ .../contextReceivers/class.fir.kt.txt | 34 ++ .../declarations/contextReceivers/class.kt | 3 +- .../compoundAssignmentOperators.fir.ir.txt | 317 ++++++++++++++++++ .../compoundAssignmentOperators.fir.kt.txt | 106 ++++++ .../compoundAssignmentOperators.kt | 1 - .../contextualFunctionConversion.fir.ir.txt | 24 ++ .../contextualFunctionConversion.fir.kt.txt | 14 + .../contextualFunctionConversion.kt | 1 - .../contextualInlineCall.fir.ir.txt | 175 ++++++++++ .../contextualInlineCall.fir.kt.txt | 55 +++ .../contextReceivers/contextualInlineCall.kt | 1 - ...ualPrimaryConstructorWithParams.fir.ir.txt | 103 ++++++ ...ualPrimaryConstructorWithParams.fir.kt.txt | 39 +++ .../contextualPrimaryConstructorWithParams.kt | 3 +- .../delegatedPropertiesOperators.fir.ir.txt | 166 +++++++++ .../delegatedPropertiesOperators.fir.kt.txt | 61 ++++ .../delegatedPropertiesOperators.kt | 3 +- .../fromKEEP/canvas.fir.ir.txt | 119 +++++++ .../fromKEEP/canvas.fir.kt.txt | 43 +++ .../contextReceivers/fromKEEP/canvas.kt | 3 +- .../fromKEEP/compareTo.fir.ir.txt | 246 ++++++++++++++ .../fromKEEP/compareTo.fir.kt.txt | 90 +++++ .../contextReceivers/fromKEEP/compareTo.kt | 3 +- .../contextReceivers/fromKEEP/dp.fir.ir.txt | 83 +++++ .../contextReceivers/fromKEEP/dp.fir.kt.txt | 30 ++ .../contextReceivers/fromKEEP/dp.kt | 3 +- .../fromKEEP/functionalType.fir.ir.txt | 122 +++++++ .../fromKEEP/functionalType.fir.kt.txt | 48 +++ .../fromKEEP/functionalType.kt | 3 +- .../fromKEEP/monoidSum.fir.ir.txt | 199 +++++++++++ .../fromKEEP/monoidSum.fir.kt.txt | 62 ++++ .../contextReceivers/fromKEEP/monoidSum.kt | 3 +- .../contextReceivers/function.fir.ir.txt | 51 +++ .../contextReceivers/function.fir.kt.txt | 23 ++ .../declarations/contextReceivers/function.kt | 3 +- .../functionalType.fir.ir.txt | 249 ++++++++++++++ .../functionalType.fir.kt.txt | 99 ++++++ .../contextReceivers/functionalType.kt | 3 +- .../genericOuterClass.fir.ir.txt | 20 +- .../genericOuterClass.fir.kt.txt | 12 +- .../iteratorOperator.fir.ir.txt | 315 +++++++++++++++++ .../iteratorOperator.fir.kt.txt | 141 ++++++++ .../contextReceivers/iteratorOperator.kt | 3 +- .../contextReceivers/lazy.fir.ir.txt | 160 +++++++++ .../contextReceivers/lazy.fir.kt.txt | 54 +++ .../declarations/contextReceivers/lazy.kt | 3 +- .../overloadPriority.fir.ir.txt | 45 +++ .../overloadPriority.fir.kt.txt | 23 ++ .../contextReceivers/overloadPriority.kt | 3 +- .../contextReceivers/overloading.fir.ir.txt | 32 ++ .../contextReceivers/overloading.fir.kt.txt | 14 + .../contextReceivers/overloading.kt | 3 +- .../passingLambdaToContextualParam.fir.ir.txt | 50 +++ .../passingLambdaToContextualParam.fir.kt.txt | 23 ++ .../passingLambdaToContextualParam.kt | 3 +- .../contextReceivers/plusMatrix.fir.ir.txt | 14 +- .../contextReceivers/plusMatrix.fir.kt.txt | 6 +- .../contextReceivers/property.fir.ir.txt | 48 +++ .../contextReceivers/property.fir.kt.txt | 14 + .../declarations/contextReceivers/property.kt | 3 +- .../thisWithCustomLabel.fir.ir.txt | 143 ++++++++ .../thisWithCustomLabel.fir.kt.txt | 55 +++ .../contextReceivers/thisWithCustomLabel.kt | 3 +- .../typeParameterAsContextReceiver.fir.ir.txt | 9 +- .../typeParameterAsContextReceiver.fir.kt.txt | 4 +- .../unaryOperators.fir.ir.txt | 238 +++++++++++++ .../unaryOperators.fir.kt.txt | 95 ++++++ .../contextReceivers/unaryOperators.kt | 1 - 75 files changed, 4710 insertions(+), 62 deletions(-) create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/class.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/function.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/function.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/property.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/property.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.kt.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt create mode 100644 compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.ir.txt new file mode 100644 index 00000000000..af57967d6dd --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.ir.txt @@ -0,0 +1,213 @@ +FILE fqName: fileName:/arrayAccessCompositeOperators.kt + CLASS CLASS name:MyContainer modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyContainer + CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:.MyContainer [primary] + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyContainer modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:i visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private + EXPRESSION_BODY + GET_VAR 'i: kotlin.Int declared in .MyContainer.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyContainer) returnType:kotlin.Int + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .MyContainer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.' type=.MyContainer origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyContainer, :kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.' type=.MyContainer origin=null + value: GET_VAR ': kotlin.Int declared in .MyContainer.' type=kotlin.Int origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.MyContainer) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .MyContainer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.component1' type=.MyContainer origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.MyContainer, i:kotlin.Int) returnType:.MyContainer + $this: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:i index:0 type:kotlin.Int + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.copy' type=.MyContainer origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (i: kotlin.Int): .MyContainer declared in .MyContainer' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .MyContainer' type=.MyContainer origin=null + i: GET_VAR 'i: kotlin.Int declared in .MyContainer.copy' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.MyContainer, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.MyContainer + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .MyContainer declared in .MyContainer.equals' type=.MyContainer origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .MyContainer.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.MyContainer + GET_VAR 'other: kotlin.Any? declared in .MyContainer.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.MyContainer [val] + TYPE_OP type=.MyContainer origin=CAST typeOperand=.MyContainer + GET_VAR 'other: kotlin.Any? declared in .MyContainer.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.equals' type=.MyContainer origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_0: .MyContainer [val] declared in .MyContainer.equals' type=.MyContainer origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.MyContainer) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .MyContainer' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.hashCode' type=.MyContainer origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.MyContainer) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .MyContainer' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="MyContainer(" + CONST String type=kotlin.String value="i=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.toString' type=.MyContainer origin=null + CONST String type=kotlin.String value=")" + PROPERTY name:operationScore visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + FUN name:get visibility:public modality:FINAL <> ($receiver:.MyContainer, _context_receiver_0:kotlin.Int, index:kotlin.Int) returnType:kotlin.Int [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:index index:1 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .get' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun get (_context_receiver_0: kotlin.Int, index: kotlin.Int): kotlin.Int [operator] declared in ' + WHEN type=kotlin.Int origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'index: kotlin.Int declared in .get' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public final fun (): kotlin.Int declared in .MyContainer' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .MyContainer declared in .get' type=.MyContainer origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Int type=kotlin.Int value=-1 + FUN name:plusAssign visibility:public modality:FINAL <> ($receiver:.MyContainer, _context_receiver_0:kotlin.Int, other:.MyContainer) returnType:kotlin.Unit [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.MyContainer + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .plusAssign' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .MyContainer' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .MyContainer declared in .plusAssign' type=.MyContainer origin=null + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .MyContainer' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .MyContainer declared in .plusAssign' type=.MyContainer origin=null + other: CALL 'public final fun (): kotlin.Int declared in .MyContainer' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .MyContainer declared in .plusAssign' type=.MyContainer origin=null + FUN name:inc visibility:public modality:FINAL <> ($receiver:.MyContainer, _context_receiver_0:kotlin.Int) returnType:.MyContainer [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .inc' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun inc (_context_receiver_0: kotlin.Int): .MyContainer [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .MyContainer' type=.MyContainer origin=null + i: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun (): kotlin.Int declared in .MyContainer' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .MyContainer declared in .inc' type=.MyContainer origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:myContainer type:.MyContainer [var] + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .MyContainer' type=.MyContainer origin=null + i: CONST Int type=kotlin.Int value=0 + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : kotlin.Int + : kotlin.Unit + receiver: CONST Int type=kotlin.Int value=1 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + CALL 'public final fun plusAssign (_context_receiver_0: kotlin.Int, other: .MyContainer): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'var myContainer: .MyContainer [var] declared in .box' type=.MyContainer origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .MyContainer' type=.MyContainer origin=null + i: CALL 'public final fun get (_context_receiver_0: kotlin.Int, index: kotlin.Int): kotlin.Int [operator] declared in ' type=kotlin.Int origin=null + $receiver: BLOCK type=.MyContainer origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.MyContainer [val] + GET_VAR 'var myContainer: .MyContainer [var] declared in .box' type=.MyContainer origin=null + SET_VAR 'var myContainer: .MyContainer [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .MyContainer [operator] declared in ' type=.MyContainer origin=null + $receiver: GET_VAR 'val tmp_1: .MyContainer [val] declared in .box.' type=.MyContainer origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: .MyContainer [val] declared in .box.' type=.MyContainer origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + index: CONST Int type=kotlin.Int value=0 + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + WHEN type=kotlin.String origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in .MyContainer' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'var myContainer: .MyContainer [var] declared in .box' type=.MyContainer origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + arg1: CONST Int type=kotlin.Int value=3 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CONST String type=kotlin.String value="OK" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.kt.txt new file mode 100644 index 00000000000..ac577512eb5 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.fir.kt.txt @@ -0,0 +1,85 @@ +data class MyContainer { + constructor(i: Int) /* primary */ { + super/*Any*/() + /* () */ + + } + + var i: Int + field = i + get + set + + operator fun component1(): Int { + return .#i + } + + fun copy(i: Int = .#i): MyContainer { + return MyContainer(i = i) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is MyContainer -> return false + } + val tmp0_other_with_cast: MyContainer = other as MyContainer + when { + EQEQ(arg0 = .#i, arg1 = tmp0_other_with_cast.#i).not() -> return false + } + return true + } + + override fun hashCode(): Int { + return .#i.hashCode() + } + + override fun toString(): String { + return "MyContainer(" + "i=" + .#i + ")" + } + +} + +var operationScore: Int + field = 0 + get + set + +operator fun MyContainer.get(_context_receiver_0: Int, index: Int): Int { + ( = ().plus(other = _context_receiver_0)) + return when { + EQEQ(arg0 = index, arg1 = 0) -> .() + else -> -1 + } +} + +operator fun MyContainer.plusAssign(_context_receiver_0: Int, other: MyContainer) { + ( = ().plus(other = _context_receiver_0)) + .( = .().plus(other = other.())) +} + +operator fun MyContainer.inc(_context_receiver_0: Int): MyContainer { + ( = ().plus(other = _context_receiver_0)) + return MyContainer(i = .().plus(other = 1)) +} + +fun box(): String { + var myContainer: MyContainer = MyContainer(i = 0) + with(receiver = 1, block = local fun Int.() { + myContainer.plusAssign(_context_receiver_0 = $this$with, other = MyContainer(i = { // BLOCK + val : MyContainer = myContainer + myContainer = .inc(_context_receiver_0 = $this$with) + + }.get(_context_receiver_0 = $this$with, index = 0))) + } +) + return when { + when { + EQEQ(arg0 = myContainer.(), arg1 = 1) -> EQEQ(arg0 = (), arg1 = 3) + else -> false + } -> "OK" + else -> "fail" + } +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.kt b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.kt index 6095afc6c43..1e640051fd8 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessCompositeOperators.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR data class MyContainer(var i: Int) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.ir.txt new file mode 100644 index 00000000000..0d69ad50e9f --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.ir.txt @@ -0,0 +1,185 @@ +FILE fqName: fileName:/arrayAccessOperators.kt + CLASS CLASS name:MyContainer modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyContainer + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:.MyContainer [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyContainer modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:s visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in .MyContainer.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyContainer) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .MyContainer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.' type=.MyContainer origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyContainer, :kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.' type=.MyContainer origin=null + value: GET_VAR ': kotlin.String declared in .MyContainer.' type=kotlin.String origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.MyContainer) returnType:kotlin.String [operator] + $this: VALUE_PARAMETER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.String [operator] declared in .MyContainer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.component1' type=.MyContainer origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.MyContainer, s:kotlin.String) returnType:.MyContainer + $this: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:s index:0 type:kotlin.String + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.copy' type=.MyContainer origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (s: kotlin.String): .MyContainer declared in .MyContainer' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) [primary] declared in .MyContainer' type=.MyContainer origin=null + s: GET_VAR 's: kotlin.String declared in .MyContainer.copy' type=kotlin.String origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.MyContainer, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.MyContainer + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .MyContainer declared in .MyContainer.equals' type=.MyContainer origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .MyContainer.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.MyContainer + GET_VAR 'other: kotlin.Any? declared in .MyContainer.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.MyContainer [val] + TYPE_OP type=.MyContainer origin=CAST typeOperand=.MyContainer + GET_VAR 'other: kotlin.Any? declared in .MyContainer.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.equals' type=.MyContainer origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR 'val tmp_0: .MyContainer [val] declared in .MyContainer.equals' type=.MyContainer origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .MyContainer' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.MyContainer) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .MyContainer' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.String' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.hashCode' type=.MyContainer origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.MyContainer) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.MyContainer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .MyContainer' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="MyContainer(" + CONST String type=kotlin.String value="s=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .MyContainer declared in .MyContainer.toString' type=.MyContainer origin=null + CONST String type=kotlin.String value=")" + FUN name:get visibility:public modality:FINAL <> ($receiver:.MyContainer, _context_receiver_0:kotlin.Int, index:kotlin.Int) returnType:kotlin.String? [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:index index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun get (_context_receiver_0: kotlin.Int, index: kotlin.Int): kotlin.String? [operator] declared in ' + WHEN type=kotlin.String? origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'index: kotlin.Int declared in .get' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR '_context_receiver_0: kotlin.Int declared in .get' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=42 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CALL 'public final fun (): kotlin.String declared in .MyContainer' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .MyContainer declared in .get' type=.MyContainer origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Null type=kotlin.Nothing? value=null + FUN name:set visibility:public modality:FINAL <> ($receiver:.MyContainer, _context_receiver_0:kotlin.Int, index:kotlin.Int, value:kotlin.String) returnType:kotlin.Unit [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.MyContainer + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:index index:1 type:kotlin.Int + VALUE_PARAMETER name:value index:2 type:kotlin.String + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=OROR + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'index: kotlin.Int declared in .set' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CONST Boolean type=kotlin.Boolean value=true + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR '_context_receiver_0: kotlin.Int declared in .set' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=42 + then: RETURN type=kotlin.Nothing from='public final fun set (_context_receiver_0: kotlin.Int, index: kotlin.Int, value: kotlin.String): kotlin.Unit [operator] declared in ' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in .MyContainer' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .MyContainer declared in .set' type=.MyContainer origin=null + : GET_VAR 'value: kotlin.String declared in .set' type=kotlin.String origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : kotlin.Int + : kotlin.String + receiver: CONST Int type=kotlin.Int value=42 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + VAR name:myContainer type:.MyContainer [val] + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) [primary] declared in .MyContainer' type=.MyContainer origin=null + s: CONST String type=kotlin.String value="fail" + CALL 'public final fun set (_context_receiver_0: kotlin.Int, index: kotlin.Int, value: kotlin.String): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val myContainer: .MyContainer [val] declared in .box.' type=.MyContainer origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST String type=kotlin.String value="OK" + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + BLOCK type=kotlin.String origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.String? [val] + CALL 'public final fun get (_context_receiver_0: kotlin.Int, index: kotlin.Int): kotlin.String? [operator] declared in ' type=kotlin.String? origin=null + $receiver: GET_VAR 'val myContainer: .MyContainer [val] declared in .box.' type=.MyContainer origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.String origin=ELVIS + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: kotlin.String? [val] declared in .box.' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST String type=kotlin.String value="fail" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: GET_VAR 'val tmp_1: kotlin.String? [val] declared in .box.' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.kt.txt new file mode 100644 index 00000000000..9bea508a8eb --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.fir.kt.txt @@ -0,0 +1,78 @@ +data class MyContainer { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + var s: String + field = s + get + set + + operator fun component1(): String { + return .#s + } + + fun copy(s: String = .#s): MyContainer { + return MyContainer(s = s) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is MyContainer -> return false + } + val tmp0_other_with_cast: MyContainer = other as MyContainer + when { + EQEQ(arg0 = .#s, arg1 = tmp0_other_with_cast.#s).not() -> return false + } + return true + } + + override fun hashCode(): Int { + return .#s.hashCode() + } + + override fun toString(): String { + return "MyContainer(" + "s=" + .#s + ")" + } + +} + +operator fun MyContainer.get(_context_receiver_0: Int, index: Int): String? { + return when { + when { + EQEQ(arg0 = index, arg1 = 0) -> EQEQ(arg0 = _context_receiver_0, arg1 = 42) + else -> false + } -> .() + else -> null + } +} + +operator fun MyContainer.set(_context_receiver_0: Int, index: Int, value: String) { + when { + when { + EQEQ(arg0 = index, arg1 = 0).not() -> true + else -> EQEQ(arg0 = _context_receiver_0, arg1 = 42).not() + } -> return Unit + } + .( = value) +} + +fun box(): String { + return with(receiver = 42, block = local fun Int.(): String { + val myContainer: MyContainer = MyContainer(s = "fail") + myContainer.set(_context_receiver_0 = $this$with, index = 0, value = "OK") + return { // BLOCK + val : String? = myContainer.get(_context_receiver_0 = $this$with, index = 0) + when { + EQEQ(arg0 = , arg1 = null) -> "fail" + else -> + } + } + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.kt b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.kt index 82231c45f3d..7c6ec1d20e9 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/arrayAccessOperators.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR data class MyContainer(var s: String) @@ -21,4 +20,4 @@ fun box(): String { myContainer[0] = "OK" myContainer[0] ?: "fail" } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt new file mode 100644 index 00000000000..02712a95634 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt @@ -0,0 +1,79 @@ +FILE fqName: fileName:/class.kt + CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer + CONSTRUCTOR visibility:public <> () returnType:.Outer [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Outer) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Outer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Outer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Outer declared in .Outer.' type=.Outer origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Inner modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inner + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Outer visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:.Outer, arg:kotlin.Any) returnType:.Inner [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Outer + VALUE_PARAMETER name:arg index:1 type:kotlin.Any + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inner modality:FINAL visibility:public superTypes:[kotlin.Any]' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Outer visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Inner declared in .Inner' type=.Inner origin=null + value: GET_VAR '_context_receiver_0: .Outer declared in .Inner.' type=.Outer origin=null + FUN name:bar visibility:public modality:FINAL <> ($this:.Inner) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.Inner + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun bar (): kotlin.Int declared in .Inner' + CALL 'public final fun (): kotlin.Int declared in .Outer' type=kotlin.Int origin=GET_PROPERTY + $this: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Outer visibility:private [final]' type=.Outer origin=null + receiver: GET_VAR ': .Inner declared in .Inner.bar' type=.Inner origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL <> (outer:.Outer) returnType:kotlin.Unit + VALUE_PARAMETER name:outer index:0 type:.Outer + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=.Inner origin=null + : .Outer + : .Inner + receiver: GET_VAR 'outer: .Outer declared in .f' type=.Outer origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Outer, .Inner> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Outer) returnType:.Inner + $receiver: VALUE_PARAMETER name:$this$with type:.Outer + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): .Inner declared in .f' + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: .Outer, arg: kotlin.Any) [primary] declared in .Inner' type=.Inner origin=null + _context_receiver_0: GET_VAR '$this$with: .Outer declared in .f.' type=.Outer origin=null + arg: CONST Int type=kotlin.Int value=3 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.kt.txt new file mode 100644 index 00000000000..be531043e1b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.kt.txt @@ -0,0 +1,34 @@ +class Outer { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: Int + field = 1 + get + +} + +class Inner { + private /* final field */ val contextReceiverField0: Outer + constructor(_context_receiver_0: Outer, arg: Any) /* primary */ { + super/*Any*/() + /* () */ + + .#contextReceiverField0 = _context_receiver_0 + } + + fun bar(): Int { + return .#contextReceiverField0.() + } + +} + +fun f(outer: Outer) { + with(receiver = outer, block = local fun Outer.(): Inner { + return Inner(_context_receiver_0 = $this$with, arg = 3) + } +) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.kt b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt index cfa072d71de..53346915b6f 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/class.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR class Outer { val x: Int = 1 @@ -14,4 +13,4 @@ fun f(outer: Outer) { with(outer) { Inner(3) } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.ir.txt new file mode 100644 index 00000000000..1859365533c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.ir.txt @@ -0,0 +1,317 @@ +FILE fqName: fileName:/compoundAssignmentOperators.kt + CLASS CLASS name:Result modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Result + CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:.Result [primary] + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Result modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:i visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private + EXPRESSION_BODY + GET_VAR 'i: kotlin.Int declared in .Result.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Result) returnType:kotlin.Int + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Result' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Result, :kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + value: GET_VAR ': kotlin.Int declared in .Result.' type=kotlin.Int origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.Result) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .Result' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.component1' type=.Result origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.Result, i:kotlin.Int) returnType:.Result + $this: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:i index:0 type:kotlin.Int + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.copy' type=.Result origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (i: kotlin.Int): .Result declared in .Result' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: GET_VAR 'i: kotlin.Int declared in .Result.copy' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Result, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Result + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .Result declared in .Result.equals' type=.Result origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .Result.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.Result + GET_VAR 'other: kotlin.Any? declared in .Result.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Result [val] + TYPE_OP type=.Result origin=CAST typeOperand=.Result + GET_VAR 'other: kotlin.Any? declared in .Result.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.equals' type=.Result origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_0: .Result [val] declared in .Result.equals' type=.Result origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.Result) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .Result' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.hashCode' type=.Result origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.Result) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .Result' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Result(" + CONST String type=kotlin.String value="i=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.toString' type=.Result origin=null + CONST String type=kotlin.String value=")" + PROPERTY name:operationScore visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + FUN name:plus visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .plus' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun plus (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .plus' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .plus' type=.Result origin=null + FUN name:plusAssign visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:kotlin.Unit [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .plusAssign' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .Result' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .Result declared in .plusAssign' type=.Result origin=null + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .plusAssign' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .plusAssign' type=.Result origin=null + FUN name:minus visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .minus' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun minus (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .minus' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .minus' type=.Result origin=null + FUN name:minusAssign visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:kotlin.Unit [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .minusAssign' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .Result' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .Result declared in .minusAssign' type=.Result origin=null + : CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .minusAssign' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .minusAssign' type=.Result origin=null + FUN name:times visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .times' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun times (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .times' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .times' type=.Result origin=null + FUN name:timesAssign visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:kotlin.Unit [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .timesAssign' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .Result' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .Result declared in .timesAssign' type=.Result origin=null + : CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .timesAssign' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .timesAssign' type=.Result origin=null + FUN name:div visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .div' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun div (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun div (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=DIV + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .div' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .div' type=.Result origin=null + FUN name:divAssign visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int, other:.Result) returnType:kotlin.Unit [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:other index:1 type:.Result + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .divAssign' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .Result' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .Result declared in .divAssign' type=.Result origin=null + : CALL 'public final fun div (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .divAssign' type=.Result origin=null + other: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'other: .Result declared in .divAssign' type=.Result origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:result type:.Result [val] + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=0 + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : kotlin.Int + : kotlin.Unit + receiver: CONST Int type=kotlin.Int value=1 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + CALL 'public final fun plusAssign (_context_receiver_0: kotlin.Int, other: .Result): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun plus (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' type=.Result origin=PLUS + $receiver: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=1 + CALL 'public final fun minusAssign (_context_receiver_0: kotlin.Int, other: .Result): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun minus (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' type=.Result origin=MINUS + $receiver: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=0 + CALL 'public final fun timesAssign (_context_receiver_0: kotlin.Int, other: .Result): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun times (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' type=.Result origin=MUL + $receiver: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=2 + CALL 'public final fun divAssign (_context_receiver_0: kotlin.Int, other: .Result): kotlin.Unit [operator] declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun div (_context_receiver_0: kotlin.Int, other: .Result): .Result [operator] declared in ' type=.Result origin=DIV + $receiver: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=4 + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + other: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=2 + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + WHEN type=kotlin.String origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + arg1: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CONST String type=kotlin.String value="OK" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.kt.txt new file mode 100644 index 00000000000..8218f247d28 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.fir.kt.txt @@ -0,0 +1,106 @@ +data class Result { + constructor(i: Int) /* primary */ { + super/*Any*/() + /* () */ + + } + + var i: Int + field = i + get + set + + operator fun component1(): Int { + return .#i + } + + fun copy(i: Int = .#i): Result { + return Result(i = i) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is Result -> return false + } + val tmp0_other_with_cast: Result = other as Result + when { + EQEQ(arg0 = .#i, arg1 = tmp0_other_with_cast.#i).not() -> return false + } + return true + } + + override fun hashCode(): Int { + return .#i.hashCode() + } + + override fun toString(): String { + return "Result(" + "i=" + .#i + ")" + } + +} + +var operationScore: Int + field = 0 + get + set + +operator fun Result.plus(_context_receiver_0: Int, other: Result): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().plus(other = other.())) +} + +operator fun Result.plusAssign(_context_receiver_0: Int, other: Result) { + ( = ().plus(other = _context_receiver_0)) + .( = .().plus(other = other.())) +} + +operator fun Result.minus(_context_receiver_0: Int, other: Result): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().minus(other = other.())) +} + +operator fun Result.minusAssign(_context_receiver_0: Int, other: Result) { + ( = ().plus(other = _context_receiver_0)) + .( = .().minus(other = other.())) +} + +operator fun Result.times(_context_receiver_0: Int, other: Result): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().times(other = other.())) +} + +operator fun Result.timesAssign(_context_receiver_0: Int, other: Result) { + ( = ().plus(other = _context_receiver_0)) + .( = .().times(other = other.())) +} + +operator fun Result.div(_context_receiver_0: Int, other: Result): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().div(other = other.())) +} + +operator fun Result.divAssign(_context_receiver_0: Int, other: Result) { + ( = ().plus(other = _context_receiver_0)) + .( = .().div(other = other.())) +} + +fun box(): String { + val result: Result = Result(i = 0) + with(receiver = 1, block = local fun Int.() { + result.plusAssign(_context_receiver_0 = $this$with, other = Result(i = 1).plus(_context_receiver_0 = $this$with, other = Result(i = 1))) + result.minusAssign(_context_receiver_0 = $this$with, other = Result(i = 1).minus(_context_receiver_0 = $this$with, other = Result(i = 0))) + result.timesAssign(_context_receiver_0 = $this$with, other = Result(i = 1).times(_context_receiver_0 = $this$with, other = Result(i = 2))) + result.divAssign(_context_receiver_0 = $this$with, other = Result(i = 4).div(_context_receiver_0 = $this$with, other = Result(i = 2))) + } +) + return when { + when { + EQEQ(arg0 = result.(), arg1 = 1) -> EQEQ(arg0 = (), arg1 = 8) + else -> false + } -> "OK" + else -> "fail" + } +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.kt b/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.kt index a415b2281db..6e40fe38b91 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/compoundAssignmentOperators.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR data class Result(var i: Int) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.ir.txt new file mode 100644 index 00000000000..8b5953bd1f9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.ir.txt @@ -0,0 +1,24 @@ +FILE fqName: fileName:/contextualFunctionConversion.kt + FUN name:withContext visibility:public modality:FINAL <> (f:kotlin.Function1) returnType:kotlin.String + VALUE_PARAMETER name:f index:0 type:kotlin.Function1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun withContext (f: kotlin.Function1): kotlin.String declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.String origin=INVOKE + $this: GET_VAR 'f: kotlin.Function1 declared in .withContext' type=kotlin.Function1 origin=VARIABLE_AS_FUNCTION + p1: CONST String type=kotlin.String value="OK" + FUN name:callWithContext visibility:public modality:FINAL <> (f:kotlin.Function1) returnType:kotlin.String + VALUE_PARAMETER name:f index:0 type:kotlin.Function1 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun callWithContext (f: kotlin.Function1): kotlin.String declared in ' + CALL 'public final fun withContext (f: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null + f: GET_VAR 'f: kotlin.Function1 declared in .callWithContext' type=kotlin.Function1 origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun callWithContext (f: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null + f: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (s:kotlin.String) returnType:kotlin.String + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (s: kotlin.String): kotlin.String declared in .box' + GET_VAR 's: kotlin.String declared in .box.' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.kt.txt new file mode 100644 index 00000000000..ea81883475c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.fir.kt.txt @@ -0,0 +1,14 @@ +fun withContext(f: Function1): String { + return f.invoke(p1 = "OK") +} + +fun callWithContext(f: Function1): String { + return withContext(f = f) +} + +fun box(): String { + return callWithContext(f = local fun (s: String): String { + return s + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.kt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.kt index 2ef5c9f8337..ebde7e4619d 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualFunctionConversion.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR fun withContext(f: context(String) () -> String) = f("OK") diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.ir.txt new file mode 100644 index 00000000000..c813ba1d380 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.ir.txt @@ -0,0 +1,175 @@ +FILE fqName: fileName:/contextualInlineCall.kt + CLASS CLASS name:Context modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Context + CONSTRUCTOR visibility:public <> () returnType:.Context [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Context modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN name:c visibility:public modality:FINAL <> ($this:.Context) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.Context + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun c (): kotlin.Int declared in .Context' + CONST Int type=kotlin.Int value=1 + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:testInline visibility:public modality:FINAL <> (_context_receiver_0:.Context) returnType:kotlin.Int [inline] + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testInline (_context_receiver_0: .Context): kotlin.Int [inline] declared in ' + CALL 'public final fun c (): kotlin.Int declared in .Context' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: .Context declared in .testInline' type=.Context origin=null + FUN name:testInlineWithArg visibility:public modality:FINAL <> (_context_receiver_0:.Context, i:kotlin.Int) returnType:kotlin.Int [inline] + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context + VALUE_PARAMETER name:i index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testInlineWithArg (_context_receiver_0: .Context, i: kotlin.Int): kotlin.Int [inline] declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR 'i: kotlin.Int declared in .testInlineWithArg' type=kotlin.Int origin=null + other: CALL 'public final fun c (): kotlin.Int declared in .Context' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: .Context declared in .testInlineWithArg' type=.Context origin=null + FUN name:testInlineWithExtensionAndArg visibility:public modality:FINAL <> ($receiver:kotlin.Int, _context_receiver_0:.Context, i:kotlin.Int) returnType:kotlin.Int [inline] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context + VALUE_PARAMETER name:i index:1 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testInlineWithExtensionAndArg (_context_receiver_0: .Context, i: kotlin.Int): kotlin.Int [inline] declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .testInlineWithExtensionAndArg' type=kotlin.Int origin=null + other: GET_VAR 'i: kotlin.Int declared in .testInlineWithExtensionAndArg' type=kotlin.Int origin=null + other: CALL 'public final fun c (): kotlin.Int declared in .Context' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: .Context declared in .testInlineWithExtensionAndArg' type=.Context origin=null + FUN name:testInlineWithExtensionAndMultipleArgs visibility:public modality:FINAL <> ($receiver:kotlin.Int, _context_receiver_0:.Context, i1:kotlin.Int, i2:kotlin.Int) returnType:kotlin.Int [inline] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context + VALUE_PARAMETER name:i1 index:1 type:kotlin.Int + VALUE_PARAMETER name:i2 index:2 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testInlineWithExtensionAndMultipleArgs (_context_receiver_0: .Context, i1: kotlin.Int, i2: kotlin.Int): kotlin.Int [inline] declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .testInlineWithExtensionAndMultipleArgs' type=kotlin.Int origin=null + other: GET_VAR 'i1: kotlin.Int declared in .testInlineWithExtensionAndMultipleArgs' type=kotlin.Int origin=null + other: GET_VAR 'i2: kotlin.Int declared in .testInlineWithExtensionAndMultipleArgs' type=kotlin.Int origin=null + other: CALL 'public final fun c (): kotlin.Int declared in .Context' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: .Context declared in .testInlineWithExtensionAndMultipleArgs' type=.Context origin=null + FUN name:testInlineWithExtensionAndMultipleContextsAndArgs visibility:public modality:FINAL <> ($receiver:kotlin.Int, _context_receiver_0:.Context, _context_receiver_1:kotlin.Any, i1:kotlin.Int, i2:kotlin.Int) returnType:kotlin.Int [inline] + contextReceiverParametersCount: 2 + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context + VALUE_PARAMETER name:_context_receiver_1 index:1 type:kotlin.Any + VALUE_PARAMETER name:i1 index:2 type:kotlin.Int + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + VALUE_PARAMETER name:i2 index:3 type:kotlin.Int + EXPRESSION_BODY + CONST Int type=kotlin.Int value=2 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testInlineWithExtensionAndMultipleContextsAndArgs (_context_receiver_0: .Context, _context_receiver_1: kotlin.Any, i1: kotlin.Int, i2: kotlin.Int): kotlin.Int [inline] declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .testInlineWithExtensionAndMultipleContextsAndArgs' type=kotlin.Int origin=null + other: GET_VAR 'i1: kotlin.Int declared in .testInlineWithExtensionAndMultipleContextsAndArgs' type=kotlin.Int origin=null + other: GET_VAR 'i2: kotlin.Int declared in .testInlineWithExtensionAndMultipleContextsAndArgs' type=kotlin.Int origin=null + other: CALL 'public final fun c (): kotlin.Int declared in .Context' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: .Context declared in .testInlineWithExtensionAndMultipleContextsAndArgs' type=.Context origin=null + other: WHEN type=kotlin.Int origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR '_context_receiver_1: kotlin.Any declared in .testInlineWithExtensionAndMultipleContextsAndArgs' type=kotlin.Any origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Int type=kotlin.Int value=0 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Int type=kotlin.Int value=1 + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + : .Context + : kotlin.Nothing + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Context' type=.Context origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Context, kotlin.Nothing> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Context) returnType:kotlin.Nothing + $receiver: VALUE_PARAMETER name:$this$with type:.Context + BLOCK_BODY + VAR name:result type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + SET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun testInline (_context_receiver_0: .Context): kotlin.Int [inline] declared in ' type=kotlin.Int origin=null + _context_receiver_0: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + SET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun testInlineWithArg (_context_receiver_0: .Context, i: kotlin.Int): kotlin.Int [inline] declared in ' type=kotlin.Int origin=null + _context_receiver_0: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + i: CONST Int type=kotlin.Int value=1 + SET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun testInlineWithExtensionAndArg (_context_receiver_0: .Context, i: kotlin.Int): kotlin.Int [inline] declared in ' type=kotlin.Int origin=null + $receiver: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + i: CONST Int type=kotlin.Int value=1 + SET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun testInlineWithExtensionAndMultipleArgs (_context_receiver_0: .Context, i1: kotlin.Int, i2: kotlin.Int): kotlin.Int [inline] declared in ' type=kotlin.Int origin=null + $receiver: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + i1: CONST Int type=kotlin.Int value=1 + i2: CONST Int type=kotlin.Int value=2 + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : kotlin.Int + : kotlin.Unit + receiver: CONST Int type=kotlin.Int value=1 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + SET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun testInlineWithExtensionAndMultipleContextsAndArgs (_context_receiver_0: .Context, _context_receiver_1: kotlin.Any, i1: kotlin.Int, i2: kotlin.Int): kotlin.Int [inline] declared in ' type=kotlin.Int origin=null + $receiver: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + _context_receiver_1: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + i1: CONST Int type=kotlin.Int value=1 + i2: CONST Int type=kotlin.Int value=2 + SET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + other: CALL 'public final fun testInlineWithExtensionAndMultipleContextsAndArgs (_context_receiver_0: .Context, _context_receiver_1: kotlin.Any, i1: kotlin.Int, i2: kotlin.Int): kotlin.Int [inline] declared in ' type=kotlin.Int origin=null + $receiver: CONST Int type=kotlin.Int value=1 + _context_receiver_0: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + _context_receiver_1: GET_VAR '$this$with: .Context declared in .box.' type=.Context origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + WHEN type=kotlin.String origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'var result: kotlin.Int [var] declared in .box.' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=23 + then: CONST String type=kotlin.String value="OK" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.kt.txt new file mode 100644 index 00000000000..eb8af7a6d1a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.fir.kt.txt @@ -0,0 +1,55 @@ +class Context { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + fun c(): Int { + return 1 + } + +} + +inline fun testInline(_context_receiver_0: Context): Int { + return _context_receiver_0.c() +} + +inline fun testInlineWithArg(_context_receiver_0: Context, i: Int): Int { + return i.plus(other = _context_receiver_0.c()) +} + +inline fun Int.testInlineWithExtensionAndArg(_context_receiver_0: Context, i: Int): Int { + return .plus(other = i).plus(other = _context_receiver_0.c()) +} + +inline fun Int.testInlineWithExtensionAndMultipleArgs(_context_receiver_0: Context, i1: Int, i2: Int): Int { + return .plus(other = i1).plus(other = i2).plus(other = _context_receiver_0.c()) +} + +inline fun Int.testInlineWithExtensionAndMultipleContextsAndArgs(_context_receiver_0: Context, _context_receiver_1: Any, i1: Int = 1, i2: Int = 2): Int { + return .plus(other = i1).plus(other = i2).plus(other = _context_receiver_0.c()).plus(other = when { + EQEQ(arg0 = _context_receiver_1, arg1 = null) -> 0 + else -> 1 + }) +} + +fun box(): String { + return with(receiver = Context(), block = local fun Context.(): Nothing { + var result: Int = 0 + result = result.plus(other = testInline(_context_receiver_0 = $this$with)) + result = result.plus(other = testInlineWithArg(_context_receiver_0 = $this$with, i = 1)) + result = result.plus(other = 1.testInlineWithExtensionAndArg(_context_receiver_0 = $this$with, i = 1)) + result = result.plus(other = 1.testInlineWithExtensionAndMultipleArgs(_context_receiver_0 = $this$with, i1 = 1, i2 = 2)) + with(receiver = 1, block = local fun Int.() { + result = result.plus(other = 1.testInlineWithExtensionAndMultipleContextsAndArgs(_context_receiver_0 = $this$with, _context_receiver_1 = $this$with, i1 = 1, i2 = 2)) + result = result.plus(other = 1.testInlineWithExtensionAndMultipleContextsAndArgs(_context_receiver_0 = $this$with, _context_receiver_1 = $this$with)) + } +) + return when { + EQEQ(arg0 = result, arg1 = 23) -> "OK" + else -> "fail" + } + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.kt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.kt index 3012f6fc156..32887fc278d 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualInlineCall.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR class Context { fun c() = 1 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt new file mode 100644 index 00000000000..10b399aa5ea --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt @@ -0,0 +1,103 @@ +FILE fqName: fileName:/contextualPrimaryConstructorWithParams.kt + CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.O + CONSTRUCTOR visibility:public <> (o:kotlin.String) returnType:.O [primary] + VALUE_PARAMETER name:o index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:o visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 'o: kotlin.String declared in .O.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.O) returnType:kotlin.String + correspondingProperty: PROPERTY name:o visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .O' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .O declared in .O.' type=.O origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:OK modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.OK + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.O visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:.O, k:kotlin.String) returnType:.OK [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.O + VALUE_PARAMETER name:k index:1 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:OK modality:FINAL visibility:public superTypes:[kotlin.Any]' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.O visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .OK declared in .OK' type=.OK origin=null + value: GET_VAR '_context_receiver_0: .O declared in .OK.' type=.O origin=null + PROPERTY name:k visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 'k: kotlin.String declared in .OK.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.OK) returnType:kotlin.String + correspondingProperty: PROPERTY name:k visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.OK + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .OK' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .OK declared in .OK.' type=.OK origin=null + PROPERTY name:result visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:result type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun (): kotlin.String declared in .O' type=kotlin.String origin=GET_PROPERTY + $this: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.O visibility:private [final]' type=.O origin=null + receiver: GET_VAR ': .OK declared in .OK' type=.OK origin=null + other: CALL 'public final fun (): kotlin.String declared in .OK' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .OK declared in .OK' type=.OK origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.OK) returnType:kotlin.String + correspondingProperty: PROPERTY name:result visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.OK + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .OK' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:result type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .OK declared in .OK.' type=.OK origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .O + : kotlin.String + receiver: CONSTRUCTOR_CALL 'public constructor (o: kotlin.String) [primary] declared in .O' type=.O origin=null + o: CONST String type=kotlin.String value="O" + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.O, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.O) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.O + BLOCK_BODY + VAR name:ok type:.OK [val] + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: .O, k: kotlin.String) [primary] declared in .OK' type=.OK origin=null + _context_receiver_0: GET_VAR '$this$with: .O declared in .box.' type=.O origin=null + k: CONST String type=kotlin.String value="K" + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun (): kotlin.String declared in .OK' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR 'val ok: .OK [val] declared in .box.' type=.OK origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.kt.txt new file mode 100644 index 00000000000..179265d91a6 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.kt.txt @@ -0,0 +1,39 @@ +class O { + constructor(o: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val o: String + field = o + get + +} + +class OK { + private /* final field */ val contextReceiverField0: O + constructor(_context_receiver_0: O, k: String) /* primary */ { + super/*Any*/() + /* () */ + + .#contextReceiverField0 = _context_receiver_0 + } + + val k: String + field = k + get + + val result: String + field = .#contextReceiverField0.().plus(other = .()) + get + +} + +fun box(): String { + return with(receiver = O(o = "O"), block = local fun O.(): String { + val ok: OK = OK(_context_receiver_0 = $this$with, k = "K") + return ok.() + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt index f7ab50bc6af..69b158479ed 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR class O(val o: String) @@ -13,4 +12,4 @@ fun box(): String { val ok = OK("K") ok.result } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.ir.txt new file mode 100644 index 00000000000..1ac12413763 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.ir.txt @@ -0,0 +1,166 @@ +FILE fqName: fileName:/delegatedPropertiesOperators.kt + PROPERTY name:operationScore visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + CLASS CLASS name:Delegate modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Delegate + CONSTRUCTOR visibility:public <> () returnType:.Delegate [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegate modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:delegateValue visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:delegateValue type:kotlin.String visibility:private + EXPRESSION_BODY + CONST String type=kotlin.String value="fail" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Delegate) returnType:kotlin.String + correspondingProperty: PROPERTY name:delegateValue visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Delegate + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Delegate' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegateValue type:kotlin.String visibility:private' type=kotlin.String origin=null + receiver: GET_VAR ': .Delegate declared in .Delegate.' type=.Delegate origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Delegate, :kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:delegateValue visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Delegate + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegateValue type:kotlin.String visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Delegate declared in .Delegate.' type=.Delegate origin=null + value: GET_VAR ': kotlin.String declared in .Delegate.' type=kotlin.String origin=null + FUN name:getValue visibility:public modality:FINAL <> ($this:.Delegate, _context_receiver_0:kotlin.Int, thisRef:kotlin.Any?, property:kotlin.reflect.KProperty<*>) returnType:kotlin.String [operator] + $this: VALUE_PARAMETER name: type:.Delegate + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:thisRef index:1 type:kotlin.Any? + VALUE_PARAMETER name:property index:2 type:kotlin.reflect.KProperty<*> + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .Delegate.getValue' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun getValue (_context_receiver_0: kotlin.Int, thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): kotlin.String [operator] declared in .Delegate' + CALL 'public final fun (): kotlin.String declared in .Delegate' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .Delegate declared in .Delegate.getValue' type=.Delegate origin=null + FUN name:setValue visibility:public modality:FINAL <> ($this:.Delegate, _context_receiver_0:kotlin.Int, thisRef:kotlin.Any?, property:kotlin.reflect.KProperty<*>, value:kotlin.String) returnType:kotlin.Unit [operator] + $this: VALUE_PARAMETER name: type:.Delegate + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:thisRef index:1 type:kotlin.Any? + VALUE_PARAMETER name:property index:2 type:kotlin.reflect.KProperty<*> + VALUE_PARAMETER name:value index:3 type:kotlin.String + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .Delegate.setValue' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in .Delegate' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .Delegate declared in .Delegate.setValue' type=.Delegate origin=null + : GET_VAR 'value: kotlin.String declared in .Delegate.setValue' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Result modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Result + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.Int visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:kotlin.Int) returnType:.Result [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Result modality:FINAL visibility:public superTypes:[kotlin.Any]' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Result declared in .Result' type=.Result origin=null + value: GET_VAR '_context_receiver_0: kotlin.Int declared in .Result.' type=kotlin.Int origin=null + PROPERTY name:s visibility:public modality:FINAL [delegated,var] + FIELD PROPERTY_DELEGATE name:s$delegate type:.Delegate visibility:private [final] + EXPRESSION_BODY + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Delegate' type=.Delegate origin=null + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Result) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [delegated,var] + $this: VALUE_PARAMETER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .Result' + CALL 'public final fun getValue (_context_receiver_0: kotlin.Int, thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): kotlin.String [operator] declared in .Delegate' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:s$delegate type:.Delegate visibility:private [final]' type=.Delegate origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + _context_receiver_0: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + thisRef: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + property: PROPERTY_REFERENCE 'public final s: kotlin.String [delegated,var]' field=null getter='public final fun (): kotlin.String declared in .Result' setter='public final fun (: kotlin.String): kotlin.Unit declared in .Result' type=kotlin.reflect.KMutableProperty1<.Result, kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE + FUN DELEGATED_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Result, :kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [delegated,var] + $this: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + CALL 'public final fun setValue (_context_receiver_0: kotlin.Int, thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: kotlin.String): kotlin.Unit [operator] declared in .Delegate' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:s$delegate type:.Delegate visibility:private [final]' type=.Delegate origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + _context_receiver_0: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + thisRef: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + property: PROPERTY_REFERENCE 'public final s: kotlin.String [delegated,var]' field=null getter='public final fun (): kotlin.String declared in .Result' setter='public final fun (: kotlin.String): kotlin.Unit declared in .Result' type=kotlin.reflect.KMutableProperty1<.Result, kotlin.String> origin=PROPERTY_REFERENCE_FOR_DELEGATE + value: GET_VAR ': kotlin.String declared in .Result.' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:result type:.Result [val] + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=.Result origin=null + : kotlin.Int + : .Result + receiver: CONST Int type=kotlin.Int value=1 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1.Result> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:.Result + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): .Result declared in .box' + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in .Result' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + : CONST String type=kotlin.String value="OK" + VAR name:returnValue type:kotlin.String [val] + CALL 'public final fun (): kotlin.String declared in .Result' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR 'val result: .Result [val] declared in .box' type=.Result origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + WHEN type=kotlin.String origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + arg1: CONST Int type=kotlin.Int value=2 + then: GET_VAR 'val returnValue: kotlin.String [val] declared in .box' type=kotlin.String origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.kt.txt new file mode 100644 index 00000000000..25cb28c5e4c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.fir.kt.txt @@ -0,0 +1,61 @@ +var operationScore: Int + field = 0 + get + set + +class Delegate { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + var delegateValue: String + field = "fail" + get + set + + operator fun getValue(_context_receiver_0: Int, thisRef: Any?, property: KProperty<*>): String { + ( = ().plus(other = _context_receiver_0)) + return .() + } + + operator fun setValue(_context_receiver_0: Int, thisRef: Any?, property: KProperty<*>, value: String) { + ( = ().plus(other = _context_receiver_0)) + .( = value) + } + +} + +class Result { + private /* final field */ val contextReceiverField0: Int + constructor(_context_receiver_0: Int) /* primary */ { + super/*Any*/() + /* () */ + + .#contextReceiverField0 = _context_receiver_0 + } + + var s: String /* by */ + field = Delegate() + get(): String { + return .#s$delegate.getValue(_context_receiver_0 = .#contextReceiverField0, thisRef = , property = Result::s) + } + set(: String) { + .#s$delegate.setValue(_context_receiver_0 = .#contextReceiverField0, thisRef = , property = Result::s, value = ) + } + +} + +fun box(): String { + val result: Result = with(receiver = 1, block = local fun Int.(): Result { + return Result(_context_receiver_0 = $this$with) + } +) + result.( = "OK") + val returnValue: String = result.() + return when { + EQEQ(arg0 = (), arg1 = 2) -> returnValue + else -> "fail" + } +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt index b4c91a7f2ed..4622a0f3308 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR // WITH_STDLIB import kotlin.reflect.KProperty @@ -33,4 +32,4 @@ fun box(): String { result.s = "OK" val returnValue = result.s return if (operationScore == 2) returnValue else "fail" -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.ir.txt new file mode 100644 index 00000000000..96b4b408924 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.ir.txt @@ -0,0 +1,119 @@ +FILE fqName: fileName:/canvas.kt + CLASS INTERFACE name:Canvas modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Canvas + PROPERTY name:suffix visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Canvas) returnType:kotlin.String + correspondingProperty: PROPERTY name:suffix visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.Canvas + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Shape modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Shape + FUN name:draw visibility:public modality:ABSTRACT <> ($this:.Shape, _context_receiver_0:.Canvas) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Shape + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Canvas + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[.Shape] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Circle + CONSTRUCTOR visibility:public <> () returnType:.Circle [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[.Shape]' + FUN name:draw visibility:public modality:FINAL <> ($this:.Circle, _context_receiver_0:.Canvas) returnType:kotlin.String + overridden: + public abstract fun draw (_context_receiver_0: .Canvas): kotlin.String declared in .Shape + $this: VALUE_PARAMETER name: type:.Circle + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Canvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun draw (_context_receiver_0: .Canvas): kotlin.String declared in .Circle' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="OK" + other: CALL 'public abstract fun (): kotlin.String declared in .Canvas' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .Canvas declared in .Circle.draw' type=.Canvas origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyCanvas + CONSTRUCTOR visibility:private <> () returnType:.MyCanvas [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas]' + PROPERTY name:suffix visibility:public modality:FINAL [val] + overridden: + public abstract suffix: kotlin.String [val] + FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.MyCanvas) returnType:kotlin.String + correspondingProperty: PROPERTY name:suffix visibility:public modality:FINAL [val] + overridden: + public abstract fun (): kotlin.String declared in .Canvas + $this: VALUE_PARAMETER name: type:.MyCanvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .MyCanvas' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .MyCanvas declared in .MyCanvas.' type=.MyCanvas origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .MyCanvas + : kotlin.String + receiver: GET_OBJECT 'CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas]' type=.MyCanvas + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.MyCanvas, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.MyCanvas) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.MyCanvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun draw (_context_receiver_0: .Canvas): kotlin.String declared in .Circle' type=kotlin.String origin=null + $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Circle' type=.Circle origin=null + _context_receiver_0: GET_VAR '$this$with: .MyCanvas declared in .box.' type=.MyCanvas origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.kt.txt new file mode 100644 index 00000000000..de3ee4a56ad --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.fir.kt.txt @@ -0,0 +1,43 @@ +interface Canvas { + abstract val suffix: String + abstract get + +} + +interface Shape { + abstract fun draw(_context_receiver_0: Canvas): String + +} + +class Circle : Shape { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun draw(_context_receiver_0: Canvas): String { + return "OK".plus(other = _context_receiver_0.()) + } + +} + +object MyCanvas : Canvas { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override val suffix: String + field = "" + override get + +} + +fun box(): String { + return with(receiver = MyCanvas, block = local fun MyCanvas.(): String { + return Circle().draw(_context_receiver_0 = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt index 95f59cbcffa..36ae09e8ed5 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR interface Canvas { val suffix: String @@ -20,4 +19,4 @@ object MyCanvas : Canvas { override val suffix = "" } -fun box() = with(MyCanvas) { Circle().draw() } \ No newline at end of file +fun box() = with(MyCanvas) { Circle().draw() } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.ir.txt new file mode 100644 index 00000000000..b28ccdfe336 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.ir.txt @@ -0,0 +1,246 @@ +FILE fqName: fileName:/compareTo.kt + CLASS CLASS name:Pair modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Pair.Pair, B of .Pair> + TYPE_PARAMETER name:A index:0 variance: superTypes:[kotlin.Any?] reified:false + TYPE_PARAMETER name:B index:1 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (first:A of .Pair, second:B of .Pair) returnType:.Pair.Pair, B of .Pair> [primary] + VALUE_PARAMETER name:first index:0 type:A of .Pair + VALUE_PARAMETER name:second index:1 type:B of .Pair + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Pair modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:first visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final] + EXPRESSION_BODY + GET_VAR 'first: A of .Pair declared in .Pair.' type=A of .Pair origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Pair.Pair, B of .Pair>) returnType:A of .Pair + correspondingProperty: PROPERTY name:first visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Pair.Pair, B of .Pair> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): A of .Pair declared in .Pair' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.' type=.Pair.Pair, B of .Pair> origin=null + PROPERTY name:second visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final] + EXPRESSION_BODY + GET_VAR 'second: B of .Pair declared in .Pair.' type=B of .Pair origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Pair.Pair, B of .Pair>) returnType:B of .Pair + correspondingProperty: PROPERTY name:second visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Pair.Pair, B of .Pair> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): B of .Pair declared in .Pair' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.' type=.Pair.Pair, B of .Pair> origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.Pair.Pair, B of .Pair>) returnType:A of .Pair [operator] + $this: VALUE_PARAMETER name: type:.Pair.Pair, B of .Pair> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): A of .Pair [operator] declared in .Pair' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.component1' type=.Pair.Pair, B of .Pair> origin=null + FUN name:component2 visibility:public modality:FINAL <> ($this:.Pair.Pair, B of .Pair>) returnType:B of .Pair [operator] + $this: VALUE_PARAMETER name: type:.Pair.Pair, B of .Pair> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component2 (): B of .Pair [operator] declared in .Pair' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.component2' type=.Pair.Pair, B of .Pair> origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.Pair.Pair, B of .Pair>, first:A of .Pair, second:B of .Pair) returnType:.Pair.Pair, B of .Pair> + $this: VALUE_PARAMETER name: type:.Pair.Pair, B of .Pair> + VALUE_PARAMETER name:first index:0 type:A of .Pair + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.copy' type=.Pair.Pair, B of .Pair> origin=null + VALUE_PARAMETER name:second index:1 type:B of .Pair + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.copy' type=.Pair.Pair, B of .Pair> origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (first: A of .Pair, second: B of .Pair): .Pair.Pair, B of .Pair> declared in .Pair' + CONSTRUCTOR_CALL 'public constructor (first: A of .Pair, second: B of .Pair) [primary] declared in .Pair' type=.Pair.Pair, B of .Pair> origin=null + : kotlin.Any + : kotlin.Any + first: GET_VAR 'first: A of .Pair declared in .Pair.copy' type=A of .Pair origin=null + second: GET_VAR 'second: B of .Pair declared in .Pair.copy' type=B of .Pair origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Pair.Pair, B of .Pair>, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Pair.Pair, B of .Pair> + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.equals' type=.Pair.Pair, B of .Pair> origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .Pair.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Pair' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.Pair.Pair, B of .Pair> + GET_VAR 'other: kotlin.Any? declared in .Pair.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Pair' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Pair.Pair, B of .Pair> [val] + TYPE_OP type=.Pair.Pair, B of .Pair> origin=CAST typeOperand=.Pair.Pair, B of .Pair> + GET_VAR 'other: kotlin.Any? declared in .Pair.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.equals' type=.Pair.Pair, B of .Pair> origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR 'val tmp_0: .Pair.Pair, B of .Pair> [val] declared in .Pair.equals' type=.Pair.Pair, B of .Pair> origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Pair' + CONST Boolean type=kotlin.Boolean value=false + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.equals' type=.Pair.Pair, B of .Pair> origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR 'val tmp_0: .Pair.Pair, B of .Pair> [val] declared in .Pair.equals' type=.Pair.Pair, B of .Pair> origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Pair' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Pair' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.Pair.Pair, B of .Pair>) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Pair.Pair, B of .Pair> + BLOCK_BODY + VAR name:result type:kotlin.Int [var] + WHEN type=kotlin.Int origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.hashCode' type=.Pair.Pair, B of .Pair> origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Int type=kotlin.Int value=0 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.hashCode' type=.Pair.Pair, B of .Pair> origin=null + SET_VAR 'var result: kotlin.Int [var] declared in .Pair.hashCode' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .Pair.hashCode' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=31 + other: WHEN type=kotlin.Int origin=null + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.hashCode' type=.Pair.Pair, B of .Pair> origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Int type=kotlin.Int value=0 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.hashCode' type=.Pair.Pair, B of .Pair> origin=null + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .Pair' + GET_VAR 'var result: kotlin.Int [var] declared in .Pair.hashCode' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.Pair.Pair, B of .Pair>) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Pair.Pair, B of .Pair> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .Pair' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Pair(" + CONST String type=kotlin.String value="first=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:first type:A of .Pair visibility:private [final]' type=A of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.toString' type=.Pair.Pair, B of .Pair> origin=null + CONST String type=kotlin.String value=", " + CONST String type=kotlin.String value="second=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:second type:B of .Pair visibility:private [final]' type=B of .Pair origin=null + receiver: GET_VAR ': .Pair.Pair, B of .Pair> declared in .Pair.toString' type=.Pair.Pair, B of .Pair> origin=null + CONST String type=kotlin.String value=")" + FUN name:compareTo visibility:public modality:FINAL ($receiver:T of .compareTo, _context_receiver_0:java.util.Comparator.compareTo>, other:T of .compareTo) returnType:kotlin.Int [operator,infix] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:T of .compareTo + VALUE_PARAMETER name:_context_receiver_0 index:0 type:java.util.Comparator.compareTo> + VALUE_PARAMETER name:other index:1 type:T of .compareTo + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun compareTo (_context_receiver_0: java.util.Comparator.compareTo>, other: T of .compareTo): kotlin.Int [operator,infix] declared in ' + CALL 'public abstract fun compare (p0: @[FlexibleNullability] T of java.util.Comparator?, p1: @[FlexibleNullability] T of java.util.Comparator?): kotlin.Int declared in java.util.Comparator' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: java.util.Comparator.compareTo> declared in .compareTo' type=java.util.Comparator.compareTo> origin=null + p0: GET_VAR ': T of .compareTo declared in .compareTo' type=T of .compareTo origin=null + p1: GET_VAR 'other: T of .compareTo declared in .compareTo' type=T of .compareTo origin=null + PROPERTY name:min visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL ($receiver:.Pair., T of .>, _context_receiver_0:java.util.Comparator.>) returnType:T of . + correspondingProperty: PROPERTY name:min visibility:public modality:FINAL [val] + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Pair., T of .> + VALUE_PARAMETER name:_context_receiver_0 index:0 type:java.util.Comparator.> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (_context_receiver_0: java.util.Comparator.>): T of . declared in ' + WHEN type=T of . origin=IF + BRANCH + if: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun compareTo (_context_receiver_0: java.util.Comparator.compareTo>, other: T of .compareTo): kotlin.Int [operator,infix] declared in ' type=kotlin.Int origin=null + : T of . + $receiver: CALL 'public final fun (): A of .Pair declared in .Pair' type=T of . origin=GET_PROPERTY + $this: GET_VAR ': .Pair., T of .> declared in .' type=.Pair., T of .> origin=null + _context_receiver_0: GET_VAR '_context_receiver_0: java.util.Comparator.> declared in .' type=java.util.Comparator.> origin=null + other: CALL 'public final fun (): B of .Pair declared in .Pair' type=T of . origin=GET_PROPERTY + $this: GET_VAR ': .Pair., T of .> declared in .' type=.Pair., T of .> origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public final fun (): A of .Pair declared in .Pair' type=T of . origin=GET_PROPERTY + $this: GET_VAR ': .Pair., T of .> declared in .' type=.Pair., T of .> origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): B of .Pair declared in .Pair' type=T of . origin=GET_PROPERTY + $this: GET_VAR ': .Pair., T of .> declared in .' type=.Pair., T of .> origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:comparator type:java.util.Comparator<@[FlexibleNullability] kotlin.String?> [val] + TYPE_OP type=java.util.Comparator<@[FlexibleNullability] kotlin.String?> origin=SAM_CONVERSION typeOperand=java.util.Comparator<@[FlexibleNullability] kotlin.String?> + FUN_EXPR type=kotlin.Function2<@[FlexibleNullability] kotlin.String?, @[FlexibleNullability] kotlin.String?, kotlin.Int> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (a:@[FlexibleNullability] kotlin.String?, b:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Int + VALUE_PARAMETER name:a index:0 type:@[FlexibleNullability] kotlin.String? + VALUE_PARAMETER name:b index:1 type:@[FlexibleNullability] kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (a: @[FlexibleNullability] kotlin.String?, b: @[FlexibleNullability] kotlin.String?): kotlin.Int declared in .box' + WHEN type=kotlin.Int origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=OROR + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'a: @[FlexibleNullability] kotlin.String? declared in .box.' type=@[FlexibleNullability] kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Boolean type=kotlin.Boolean value=true + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'b: @[FlexibleNullability] kotlin.String? declared in .box.' type=@[FlexibleNullability] kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + then: CONST Int type=kotlin.Int value=0 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public open fun compareTo (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'a: @[FlexibleNullability] kotlin.String? declared in .box.' type=@[FlexibleNullability] kotlin.String? origin=null + other: CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'b: @[FlexibleNullability] kotlin.String? declared in .box.' type=@[FlexibleNullability] kotlin.String? origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : java.util.Comparator<@[FlexibleNullability] kotlin.String?> + : kotlin.String + receiver: GET_VAR 'val comparator: java.util.Comparator<@[FlexibleNullability] kotlin.String?> [val] declared in .box' type=java.util.Comparator<@[FlexibleNullability] kotlin.String?> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:java.util.Comparator<@[FlexibleNullability] kotlin.String?>) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:java.util.Comparator<@[FlexibleNullability] kotlin.String?> + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun (_context_receiver_0: java.util.Comparator.>): T of . declared in ' type=kotlin.String origin=GET_PROPERTY + : kotlin.String + $receiver: CONSTRUCTOR_CALL 'public constructor (first: A of .Pair, second: B of .Pair) [primary] declared in .Pair' type=.Pair origin=null + : kotlin.String + : kotlin.String + first: CONST String type=kotlin.String value="OK" + second: CONST String type=kotlin.String value="fail" + _context_receiver_0: GET_VAR '$this$with: java.util.Comparator<@[FlexibleNullability] kotlin.String?> declared in .box.' type=java.util.Comparator<@[FlexibleNullability] kotlin.String?> origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.kt.txt new file mode 100644 index 00000000000..4c3c3c04443 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.fir.kt.txt @@ -0,0 +1,90 @@ +data class Pair { + constructor(first: A, second: B) /* primary */ { + super/*Any*/() + /* () */ + + } + + val first: A + field = first + get + + val second: B + field = second + get + + operator fun component1(): A { + return .#first + } + + operator fun component2(): B { + return .#second + } + + fun copy(first: A = .#first, second: B = .#second): Pair { + return Pair(first = first, second = second) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is Pair -> return false + } + val tmp0_other_with_cast: Pair = other as Pair + when { + EQEQ(arg0 = .#first, arg1 = tmp0_other_with_cast.#first).not() -> return false + } + when { + EQEQ(arg0 = .#second, arg1 = tmp0_other_with_cast.#second).not() -> return false + } + return true + } + + override fun hashCode(): Int { + var result: Int = when { + EQEQ(arg0 = .#first, arg1 = null) -> 0 + else -> .#first.hashCode() + } + result = result.times(other = 31).plus(other = when { + EQEQ(arg0 = .#second, arg1 = null) -> 0 + else -> .#second.hashCode() + }) + return result + } + + override fun toString(): String { + return "Pair(" + "first=" + .#first + ", " + "second=" + .#second + ")" + } + +} + +infix operator fun T.compareTo(_context_receiver_0: Comparator, other: T): Int { + return _context_receiver_0.compare(p0 = , p1 = other) +} + +val Pair.min: T + get(_context_receiver_0: Comparator): T { + return when { + less(arg0 = .().compareTo(_context_receiver_0 = _context_receiver_0, other = .()), arg1 = 0) -> .() + else -> .() + } + } + +fun box(): String { + val comparator: Comparator<@FlexibleNullability String?> = local fun (a: @FlexibleNullability String?, b: @FlexibleNullability String?): Int { + return when { + when { + EQEQ(arg0 = a, arg1 = null) -> true + else -> EQEQ(arg0 = b, arg1 = null) + } -> 0 + else -> a.().compareTo(other = b.()) + } + } + /*-> Comparator<@FlexibleNullability String?> */ + return with, String>(receiver = comparator, block = local fun Comparator<@FlexibleNullability String?>.(): String { + return Pair(first = "OK", second = "fail").(_context_receiver_0 = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt index eb7443d7e12..0cf7e3a6ced 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR data class Pair(val first: A, val second: B) @@ -17,4 +16,4 @@ fun box(): String { return with(comparator) { Pair("OK", "fail").min } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt new file mode 100644 index 00000000000..a41dc143fc1 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.ir.txt @@ -0,0 +1,83 @@ +FILE fqName: fileName:/dp.kt + CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.View + CONSTRUCTOR visibility:public <> () returnType:.View [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:coefficient visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.View) returnType:kotlin.Int + correspondingProperty: PROPERTY name:coefficient visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.View + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .View' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .View declared in .View.' type=.View origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:dp visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Int, _context_receiver_0:.View) returnType:kotlin.Int + correspondingProperty: PROPERTY name:dp visibility:public modality:FINAL [val] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.View + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (_context_receiver_0: .View): kotlin.Int declared in ' + CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CALL 'public final fun (): kotlin.Int declared in .View' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .View declared in .' type=.View origin=null + other: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + : .View + : kotlin.Nothing + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .View' type=.View origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.View, kotlin.Nothing> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.View) returnType:kotlin.Nothing + $receiver: VALUE_PARAMETER name:$this$with type:.View + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + : kotlin.Int + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=10 + transform: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:it index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Int declared in .box.' + CALL 'public final fun (_context_receiver_0: .View): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'it: kotlin.Int declared in .box..' type=kotlin.Int origin=null + _context_receiver_0: GET_VAR '$this$with: .View declared in .box.' type=.View origin=null + arg1: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=42 + CONST Int type=kotlin.Int value=84 + CONST Int type=kotlin.Int value=420 + then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt new file mode 100644 index 00000000000..5a32cbb90f7 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.fir.kt.txt @@ -0,0 +1,30 @@ +class View { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val coefficient: Int + field = 42 + get + +} + +val Int.dp: Int + get(_context_receiver_0: View): Int { + return _context_receiver_0.().times(other = ) + } + +fun box(): String { + with(receiver = View(), block = local fun View.(): Nothing { + when { + EQEQ(arg0 = listOf(elements = [1, 2, 10]).map(transform = local fun (it: Int): Int { + return it.(_context_receiver_0 = $this$with) + } +), arg1 = listOf(elements = [42, 84, 420])) -> return "OK" + } + return "fail" + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt index 253b7993149..06dc09c49cc 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR // WITH_STDLIB class View { @@ -16,4 +15,4 @@ fun box(): String { } return "fail" } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.ir.txt new file mode 100644 index 00000000000..2a7abf8bd12 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.ir.txt @@ -0,0 +1,122 @@ +FILE fqName: fileName:/functionalType.kt + CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Param + CONSTRUCTOR visibility:public <> () returnType:.Param [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.O + CONSTRUCTOR visibility:public <> () returnType:.O [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:o visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="O" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.O) returnType:kotlin.String + correspondingProperty: PROPERTY name:o visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .O' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .O declared in .O.' type=.O origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K + CONSTRUCTOR visibility:public <> () returnType:.K [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:k visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="K" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.K) returnType:kotlin.String + correspondingProperty: PROPERTY name:k visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.K + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .K' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .K declared in .K.' type=.K origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL ($receiver:.K, _context_receiver_0:.O, g:@[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, T of .f>) returnType:T of .f + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.K + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.O + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, T of .f> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (_context_receiver_0: .O, g: @[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, T of .f>): T of .f declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function3, p2: P2 of kotlin.Function3, p3: P3 of kotlin.Function3): R of kotlin.Function3 [operator] declared in kotlin.Function3' type=T of .f origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, T of .f> declared in .f' type=@[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, T of .f> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR '_context_receiver_0: .O declared in .f' type=.O origin=null + p2: GET_VAR ': .K declared in .f' type=.K origin=null + p3: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .O + : kotlin.String + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .O' type=.O origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.O, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.O) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun f (_context_receiver_0: .O, g: @[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, T of .f>): T of .f declared in ' type=kotlin.String origin=null + : kotlin.String + $receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K' type=.K origin=null + _context_receiver_0: GET_VAR '$this$with: .O declared in .box.' type=.O origin=null + g: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function3<.O, .K, .Param, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.K, _context_receiver_0:.O, it:.Param) returnType:kotlin.String + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name:$this$f type:.K + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.O + VALUE_PARAMETER name:it index:1 type:.Param + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (_context_receiver_0: .O, it: .Param): kotlin.String declared in .box.' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun (): kotlin.String declared in .O' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this$with: .O declared in .box.' type=.O origin=null + other: CALL 'public final fun (): kotlin.String declared in .K' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this$f: .K declared in .box..' type=.K origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.kt.txt new file mode 100644 index 00000000000..5dd11b64d67 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.fir.kt.txt @@ -0,0 +1,48 @@ +class Param { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class O { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val o: String + field = "O" + get + +} + +class K { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val k: String + field = "K" + get + +} + +fun K.f(_context_receiver_0: O, g: @ExtensionFunctionType Function3): T { + return g.invoke(p1 = _context_receiver_0, p2 = , p3 = Param()) +} + +fun box(): String { + return with(receiver = O(), block = local fun O.(): String { + return K().f(_context_receiver_0 = $this$with, g = local fun K.(_context_receiver_0: O, it: Param): String { + return $this$with.().plus(other = $this$f.()) + } +) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt index b869312df46..31534e1fac5 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR class Param class O { @@ -15,4 +14,4 @@ fun K.f(g: context(O) K.(Param) -> T) = g(this@O, this@K, Param()) fun box() = with(O()) { K().f { o + k } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.ir.txt new file mode 100644 index 00000000000..72c8841fcbe --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.ir.txt @@ -0,0 +1,199 @@ +FILE fqName: fileName:/monoidSum.kt + CLASS INTERFACE name:Semigroup modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Semigroup.Semigroup> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN name:combine visibility:public modality:ABSTRACT <> ($this:.Semigroup.Semigroup>, $receiver:T of .Semigroup, other:T of .Semigroup) returnType:T of .Semigroup [infix] + $this: VALUE_PARAMETER name: type:.Semigroup.Semigroup> + $receiver: VALUE_PARAMETER name: type:T of .Semigroup + VALUE_PARAMETER name:other index:0 type:T of .Semigroup + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Monoid modality:ABSTRACT visibility:public superTypes:[.Semigroup.Monoid>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Monoid.Monoid> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + PROPERTY name:unit visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Monoid.Monoid>) returnType:T of .Monoid + correspondingProperty: PROPERTY name:unit visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.Monoid.Monoid> + FUN FAKE_OVERRIDE name:combine visibility:public modality:ABSTRACT <> ($this:.Semigroup.Semigroup>, $receiver:T of .Monoid, other:T of .Monoid) returnType:T of .Monoid [fake_override,infix] + overridden: + public abstract fun combine (other: T of .Semigroup): T of .Semigroup [infix] declared in .Semigroup + $this: VALUE_PARAMETER name: type:.Semigroup.Semigroup> + $receiver: VALUE_PARAMETER name: type:T of .Monoid + VALUE_PARAMETER name:other index:0 type:T of .Monoid + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IntMonoid + CONSTRUCTOR visibility:private <> () returnType:.IntMonoid [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid]' + FUN name:combine visibility:public modality:FINAL <> ($this:.IntMonoid, $receiver:kotlin.Int, other:kotlin.Int) returnType:kotlin.Int [infix] + overridden: + public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid + $this: VALUE_PARAMETER name: type:.IntMonoid + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:other index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun combine (other: kotlin.Int): kotlin.Int [infix] declared in .IntMonoid' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .IntMonoid.combine' type=kotlin.Int origin=null + other: GET_VAR 'other: kotlin.Int declared in .IntMonoid.combine' type=kotlin.Int origin=null + PROPERTY name:unit visibility:public modality:FINAL [val] + overridden: + public abstract unit: T of .Monoid [val] + FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.IntMonoid) returnType:kotlin.Int + correspondingProperty: PROPERTY name:unit visibility:public modality:FINAL [val] + overridden: + public abstract fun (): T of .Monoid declared in .Monoid + $this: VALUE_PARAMETER name: type:.IntMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .IntMonoid' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IntMonoid declared in .IntMonoid.' type=.IntMonoid origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.StringMonoid + CONSTRUCTOR visibility:private <> () returnType:.StringMonoid [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid]' + FUN name:combine visibility:public modality:FINAL <> ($this:.StringMonoid, $receiver:kotlin.String, other:kotlin.String) returnType:kotlin.String [infix] + overridden: + public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid + $this: VALUE_PARAMETER name: type:.StringMonoid + $receiver: VALUE_PARAMETER name: type:kotlin.String + VALUE_PARAMETER name:other index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun combine (other: kotlin.String): kotlin.String [infix] declared in .StringMonoid' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: GET_VAR ': kotlin.String declared in .StringMonoid.combine' type=kotlin.String origin=null + other: GET_VAR 'other: kotlin.String declared in .StringMonoid.combine' type=kotlin.String origin=null + PROPERTY name:unit visibility:public modality:FINAL [val] + overridden: + public abstract unit: T of .Monoid [val] + FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.StringMonoid) returnType:kotlin.String + correspondingProperty: PROPERTY name:unit visibility:public modality:FINAL [val] + overridden: + public abstract fun (): T of .Monoid declared in .Monoid + $this: VALUE_PARAMETER name: type:.StringMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .StringMonoid' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .StringMonoid declared in .StringMonoid.' type=.StringMonoid origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:sum visibility:public modality:FINAL ($receiver:kotlin.collections.List.sum>, _context_receiver_0:.Monoid.sum>) returnType:T of .sum + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.sum> + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Monoid.sum> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun sum (_context_receiver_0: .Monoid.sum>): T of .sum declared in ' + CALL 'public final fun fold (initial: R of kotlin.collections.CollectionsKt.fold, operation: kotlin.Function2): R of kotlin.collections.CollectionsKt.fold [inline] declared in kotlin.collections.CollectionsKt' type=T of .sum origin=null + : T of .sum + : T of .sum + $receiver: GET_VAR ': kotlin.collections.List.sum> declared in .sum' type=kotlin.collections.List.sum> origin=null + initial: CALL 'public abstract fun (): T of .Monoid declared in .Monoid' type=T of .sum origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .Monoid.sum> declared in .sum' type=.Monoid.sum> origin=null + operation: FUN_EXPR type=kotlin.Function2.sum, T of .sum, T of .sum> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (acc:T of .sum, e:T of .sum) returnType:T of .sum + VALUE_PARAMETER name:acc index:0 type:T of .sum + VALUE_PARAMETER name:e index:1 type:T of .sum + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (acc: T of .sum, e: T of .sum): T of .sum declared in .sum' + CALL 'public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid' type=T of .sum origin=null + $this: GET_VAR '_context_receiver_0: .Monoid.sum> declared in .sum' type=.Monoid.sum> origin=null + $receiver: GET_VAR 'acc: T of .sum declared in .sum.' type=T of .sum origin=null + other: GET_VAR 'e: T of .sum declared in .sum.' type=T of .sum origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : .IntMonoid + : kotlin.Int + receiver: GET_OBJECT 'CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid]' type=.IntMonoid + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.IntMonoid, kotlin.Int> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.IntMonoid) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:.IntMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .box' + CALL 'public final fun sum (_context_receiver_0: .Monoid.sum>): T of .sum declared in ' type=kotlin.Int origin=null + : kotlin.Int + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=3 + _context_receiver_0: GET_VAR '$this$with: .IntMonoid declared in .box.' type=.IntMonoid origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .StringMonoid + : kotlin.String + receiver: GET_OBJECT 'CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid]' type=.StringMonoid + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.StringMonoid, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.StringMonoid) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.StringMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun sum (_context_receiver_0: .Monoid.sum>): T of .sum declared in ' type=kotlin.String origin=null + : kotlin.String + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.String + elements: VARARG type=kotlin.Array varargElementType=kotlin.String + CONST String type=kotlin.String value="O" + CONST String type=kotlin.String value="K" + _context_receiver_0: GET_VAR '$this$with: .StringMonoid declared in .box.' type=.StringMonoid origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.kt.txt new file mode 100644 index 00000000000..4fe6b98b2c3 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.fir.kt.txt @@ -0,0 +1,62 @@ +interface Semigroup { + abstract infix fun T.combine(other: T): T + +} + +interface Monoid : Semigroup { + abstract val unit: T + abstract get + +} + +object IntMonoid : Monoid { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override infix fun Int.combine(other: Int): Int { + return .plus(other = other) + } + + override val unit: Int + field = 0 + override get + +} + +object StringMonoid : Monoid { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override infix fun String.combine(other: String): String { + return .plus(other = other) + } + + override val unit: String + field = "" + override get + +} + +fun List.sum(_context_receiver_0: Monoid): T { + return .fold(initial = _context_receiver_0.(), operation = local fun (acc: T, e: T): T { + return (_context_receiver_0, acc).combine(other = e) + } +) +} + +fun box(): String { + with(receiver = IntMonoid, block = local fun IntMonoid.(): Int { + return listOf(elements = [1, 2, 3]).sum(_context_receiver_0 = $this$with) + } +) /*~> Unit */ + return with(receiver = StringMonoid, block = local fun StringMonoid.(): String { + return listOf(elements = ["O", "K"]).sum(_context_receiver_0 = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt index 2c9460bd69b..a90dd8afdcc 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR // WITH_STDLIB interface Semigroup { @@ -29,4 +28,4 @@ fun box(): String { return with(StringMonoid) { listOf("O", "K").sum() } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/function.fir.ir.txt new file mode 100644 index 00000000000..2cefb5b030d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.fir.ir.txt @@ -0,0 +1,51 @@ +FILE fqName: fileName:/function.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:foo visibility:public modality:FINAL <> (_context_receiver_0:.C) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .C declared in .foo' type=.C origin=null + FUN name:bar visibility:public modality:FINAL <> (c:.C) returnType:kotlin.Unit + VALUE_PARAMETER name:c index:0 type:.C + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .C + : kotlin.Unit + receiver: GET_VAR 'c: .C declared in .bar' type=.C origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.C + BLOCK_BODY + CALL 'public final fun foo (_context_receiver_0: .C): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .bar.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/function.fir.kt.txt new file mode 100644 index 00000000000..a2b63fa51c5 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.fir.kt.txt @@ -0,0 +1,23 @@ +class C { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val c: Int + field = 42 + get + +} + +fun foo(_context_receiver_0: C) { + _context_receiver_0.() /*~> Unit */ +} + +fun bar(c: C) { + with(receiver = c, block = local fun C.() { + foo(_context_receiver_0 = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.kt b/compiler/testData/ir/irText/declarations/contextReceivers/function.kt index 4d59b377438..b6ed9116aed 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/function.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR class C { val c = 42 @@ -14,4 +13,4 @@ fun bar(c: C) { with(c) { foo() } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.ir.txt new file mode 100644 index 00000000000..ae2b6af8cdf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.ir.txt @@ -0,0 +1,249 @@ +FILE fqName: fileName:/functionalType.kt + CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Param + CONSTRUCTOR visibility:public <> () returnType:.Param [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:R modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.R + CONSTRUCTOR visibility:public <> () returnType:.R [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:R modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:r visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:r type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.R) returnType:kotlin.Int + correspondingProperty: PROPERTY name:r visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.R + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .R' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:r type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .R declared in .R.' type=.R origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f1 visibility:public modality:FINAL <> ($receiver:.R, _context_receiver_0:.C, g:@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit>) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.R + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function3, p2: P2 of kotlin.Function3, p3: P3 of kotlin.Function3): R of kotlin.Function3 [operator] declared in kotlin.Function3' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> declared in .f1' type=@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR '_context_receiver_0: .C declared in .f1' type=.C origin=null + p2: GET_VAR ': .R declared in .f1' type=.R origin=null + p3: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:f2 visibility:public modality:FINAL <> (_context_receiver_0:.C, g:kotlin.Function2<.C, .Param, kotlin.Unit>) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER name:g index:1 type:kotlin.Function2<.C, .Param, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: kotlin.Function2<.C, .Param, kotlin.Unit> declared in .f2' type=kotlin.Function2<.C, .Param, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR '_context_receiver_0: .C declared in .f2' type=.C origin=null + p2: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:f3 visibility:public modality:FINAL <> ($receiver:.R, _context_receiver_0:.C, g:@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit>) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.R + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> declared in .f3' type=@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR '_context_receiver_0: .C declared in .f3' type=.C origin=null + p2: GET_VAR ': .R declared in .f3' type=.R origin=null + FUN name:f4 visibility:public modality:FINAL <> (_context_receiver_0:.C, g:kotlin.Function1<.C, kotlin.Unit>) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER name:g index:1 type:kotlin.Function1<.C, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: kotlin.Function1<.C, kotlin.Unit> declared in .f4' type=kotlin.Function1<.C, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR '_context_receiver_0: .C declared in .f4' type=.C origin=null + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:lf1 type:@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> [val] + FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R, _context_receiver_0:.C, :.Param) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.R + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER UNDERSCORE_PARAMETER name: index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .R declared in .test.' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .C declared in .test.' type=.C origin=null + VAR name:lf2 type:kotlin.Function2<.C, .Param, kotlin.Unit> [val] + FUN_EXPR type=kotlin.Function2<.C, .Param, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (_context_receiver_0:.C, :.Param) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER UNDERSCORE_PARAMETER name: index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .C declared in .test.' type=.C origin=null + VAR name:lf3 type:@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> [val] + FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R, _context_receiver_0:.C) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.R + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .R declared in .test.' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .C declared in .test.' type=.C origin=null + VAR name:lf4 type:kotlin.Function1<.C, kotlin.Unit> [val] + FUN_EXPR type=kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (_context_receiver_0:.C) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .C declared in .test.' type=.C origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .C + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .test' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .R + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .R' type=.R origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.R, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.R + BLOCK_BODY + CALL 'public final fun f1 (_context_receiver_0: .C, g: @[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR '$this$with: .R declared in .test..' type=.R origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: GET_VAR 'val lf1: @[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> [val] declared in .test' type=@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=null + CALL 'public final fun f1 (_context_receiver_0: .C, g: @[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR '$this$with: .R declared in .test..' type=.R origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R, _context_receiver_0:.C, :.Param) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name:$this$f1 type:.R + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER UNDERSCORE_PARAMETER name: index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$f1: .R declared in .test...' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + CALL 'public final fun f2 (_context_receiver_0: .C, g: kotlin.Function2<.C, .Param, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: GET_VAR 'val lf2: kotlin.Function2<.C, .Param, kotlin.Unit> [val] declared in .test' type=kotlin.Function2<.C, .Param, kotlin.Unit> origin=null + CALL 'public final fun f2 (_context_receiver_0: .C, g: kotlin.Function2<.C, .Param, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: FUN_EXPR type=kotlin.Function2<.C, .Param, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (_context_receiver_0:.C, :.Param) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + VALUE_PARAMETER UNDERSCORE_PARAMETER name: index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + CALL 'public final fun f3 (_context_receiver_0: .C, g: @[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR '$this$with: .R declared in .test..' type=.R origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: GET_VAR 'val lf3: @[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> [val] declared in .test' type=@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> origin=null + CALL 'public final fun f3 (_context_receiver_0: .C, g: @[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + $receiver: GET_VAR '$this$with: .R declared in .test..' type=.R origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<.C, .R, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R, _context_receiver_0:.C) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name:$this$f3 type:.R + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$f3: .R declared in .test...' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + CALL 'public final fun f4 (_context_receiver_0: .C, g: kotlin.Function1<.C, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: GET_VAR 'val lf4: kotlin.Function1<.C, kotlin.Unit> [val] declared in .test' type=kotlin.Function1<.C, kotlin.Unit> origin=null + CALL 'public final fun f4 (_context_receiver_0: .C, g: kotlin.Function1<.C, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + g: FUN_EXPR type=kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (_context_receiver_0:.C) returnType:kotlin.Unit + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.kt.txt new file mode 100644 index 00000000000..478a6ced6b7 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.fir.kt.txt @@ -0,0 +1,99 @@ +class Param { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class C { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val c: Int + field = 42 + get + +} + +class R { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val r: Int + field = 42 + get + +} + +fun R.f1(_context_receiver_0: C, g: @ExtensionFunctionType Function3) { + g.invoke(p1 = _context_receiver_0, p2 = , p3 = Param()) +} + +fun f2(_context_receiver_0: C, g: Function2) { + g.invoke(p1 = _context_receiver_0, p2 = Param()) +} + +fun R.f3(_context_receiver_0: C, g: @ExtensionFunctionType Function2) { + g.invoke(p1 = _context_receiver_0, p2 = ) +} + +fun f4(_context_receiver_0: C, g: Function1) { + g.invoke(p1 = _context_receiver_0) +} + +fun test() { + val lf1: @ExtensionFunctionType Function3 = local fun R.(_context_receiver_0: C, : Param) { + .() /*~> Unit */ + _context_receiver_0.() /*~> Unit */ + } + + val lf2: Function2 = local fun (_context_receiver_0: C, : Param) { + _context_receiver_0.() /*~> Unit */ + } + + val lf3: @ExtensionFunctionType Function2 = local fun R.(_context_receiver_0: C) { + .() /*~> Unit */ + _context_receiver_0.() /*~> Unit */ + } + + val lf4: Function1 = local fun (_context_receiver_0: C) { + _context_receiver_0.() /*~> Unit */ + } + + with(receiver = C(), block = local fun C.() { + return with(receiver = R(), block = local fun R.() { + $this$with.f1(_context_receiver_0 = $this$with, g = lf1) + $this$with.f1(_context_receiver_0 = $this$with, g = local fun R.(_context_receiver_0: C, : Param) { + $this$f1.() /*~> Unit */ + $this$with.() /*~> Unit */ + } +) + f2(_context_receiver_0 = $this$with, g = lf2) + f2(_context_receiver_0 = $this$with, g = local fun (_context_receiver_0: C, : Param) { + $this$with.() /*~> Unit */ + } +) + $this$with.f3(_context_receiver_0 = $this$with, g = lf3) + $this$with.f3(_context_receiver_0 = $this$with, g = local fun R.(_context_receiver_0: C) { + $this$f3.() /*~> Unit */ + $this$with.() /*~> Unit */ + } +) + f4(_context_receiver_0 = $this$with, g = lf4) + f4(_context_receiver_0 = $this$with, g = local fun (_context_receiver_0: C) { + $this$with.() /*~> Unit */ + } +) + } +) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt index 8e2ba41675b..06ffff7c30c 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR class Param class C { @@ -70,4 +69,4 @@ fun test() { } } } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt index 83149cd7480..5e9b06f4332 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt @@ -2,10 +2,15 @@ FILE fqName: fileName:/genericOuterClass.kt CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.A> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - CONSTRUCTOR visibility:public <> () returnType:.A.A> [primary] + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:T of .A visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:T of .A) returnType:.A.A> [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:T of .A BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:T of .A visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .A.A> declared in .A' type=.A.A> origin=null + value: GET_VAR '_context_receiver_0: T of .A declared in .A.' type=T of .A origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -22,10 +27,15 @@ FILE fqName: fileName:/genericOuterClass.kt CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B

.B> TYPE_PARAMETER name:P index:0 variance: superTypes:[kotlin.Any?] reified:false - CONSTRUCTOR visibility:public <> () returnType:.B

.B> [primary] + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.collections.Collection

.B> visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:kotlin.collections.Collection

.B>) returnType:.B

.B> [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.collections.Collection

.B> BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.collections.Collection

.B> visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .B

.B> declared in .B' type=.B

.B> origin=null + value: GET_VAR '_context_receiver_0: kotlin.collections.Collection

.B> declared in .B.' type=kotlin.collections.Collection

.B> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any @@ -43,11 +53,13 @@ FILE fqName: fileName:/genericOuterClass.kt $receiver: VALUE_PARAMETER name: type:kotlin.Int BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: T of .A) [primary] declared in .A' type=.A origin=null : kotlin.Int + _context_receiver_0: GET_VAR ': kotlin.Int declared in .foo' type=kotlin.Int origin=null FUN name:bar visibility:public modality:FINAL <> ($receiver:kotlin.collections.Collection) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:kotlin.collections.Collection BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CONSTRUCTOR_CALL 'public constructor () [primary] declared in .B' type=.B origin=null + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: kotlin.collections.Collection

.B>) [primary] declared in .B' type=.B origin=null : kotlin.Int + _context_receiver_0: GET_VAR ': kotlin.collections.Collection declared in .bar' type=kotlin.collections.Collection origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt index 4336b94350c..37477d3faee 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt @@ -1,25 +1,29 @@ class A { - constructor() /* primary */ { + private /* final field */ val contextReceiverField0: T + constructor(_context_receiver_0: T) /* primary */ { super/*Any*/() /* () */ + .#contextReceiverField0 = _context_receiver_0 } } class B

{ - constructor() /* primary */ { + private /* final field */ val contextReceiverField0: Collection

+ constructor(_context_receiver_0: Collection

) /* primary */ { super/*Any*/() /* () */ + .#contextReceiverField0 = _context_receiver_0 } } fun Int.foo() { - A() /*~> Unit */ + A(_context_receiver_0 = ) /*~> Unit */ } fun Collection.bar() { - B() /*~> Unit */ + B(_context_receiver_0 = ) /*~> Unit */ } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.ir.txt new file mode 100644 index 00000000000..9048269ea03 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.ir.txt @@ -0,0 +1,315 @@ +FILE fqName: fileName:/iteratorOperator.kt + CLASS CLASS name:Counter modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Counter + CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:.Counter [primary] + VALUE_PARAMETER name:i index:0 type:kotlin.Int + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Counter modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:i visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private + EXPRESSION_BODY + GET_VAR 'i: kotlin.Int declared in .Counter.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Counter) returnType:kotlin.Int + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Counter + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Counter' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Counter declared in .Counter.' type=.Counter origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Counter, :kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [var] + $this: VALUE_PARAMETER name: type:.Counter + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Unit origin=null + receiver: GET_VAR ': .Counter declared in .Counter.' type=.Counter origin=null + value: GET_VAR ': kotlin.Int declared in .Counter.' type=kotlin.Int origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.Counter) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.Counter + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .Counter' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Counter declared in .Counter.component1' type=.Counter origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.Counter, i:kotlin.Int) returnType:.Counter + $this: VALUE_PARAMETER name: type:.Counter + VALUE_PARAMETER name:i index:0 type:kotlin.Int + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Counter declared in .Counter.copy' type=.Counter origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (i: kotlin.Int): .Counter declared in .Counter' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Counter' type=.Counter origin=null + i: GET_VAR 'i: kotlin.Int declared in .Counter.copy' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Counter, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Counter + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .Counter declared in .Counter.equals' type=.Counter origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .Counter.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Counter' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.Counter + GET_VAR 'other: kotlin.Any? declared in .Counter.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Counter' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Counter [val] + TYPE_OP type=.Counter origin=CAST typeOperand=.Counter + GET_VAR 'other: kotlin.Any? declared in .Counter.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Counter declared in .Counter.equals' type=.Counter origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_0: .Counter [val] declared in .Counter.equals' type=.Counter origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Counter' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Counter' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.Counter) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Counter + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .Counter' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Counter declared in .Counter.hashCode' type=.Counter origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.Counter) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Counter + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .Counter' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Counter(" + CONST String type=kotlin.String value="i=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private' type=kotlin.Int origin=null + receiver: GET_VAR ': .Counter declared in .Counter.toString' type=.Counter origin=null + CONST String type=kotlin.String value=")" + CLASS CLASS name:CounterConfig modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.CounterConfig + CONSTRUCTOR visibility:public <> (max:kotlin.Int) returnType:.CounterConfig [primary] + VALUE_PARAMETER name:max index:0 type:kotlin.Int + EXPRESSION_BODY + CONST Int type=kotlin.Int value=10 + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:CounterConfig modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:max visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'max: kotlin.Int declared in .CounterConfig.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.CounterConfig) returnType:kotlin.Int + correspondingProperty: PROPERTY name:max visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.CounterConfig + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .CounterConfig' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .CounterConfig declared in .CounterConfig.' type=.CounterConfig origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.CounterConfig) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.CounterConfig + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .CounterConfig' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .CounterConfig declared in .CounterConfig.component1' type=.CounterConfig origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.CounterConfig, max:kotlin.Int) returnType:.CounterConfig + $this: VALUE_PARAMETER name: type:.CounterConfig + VALUE_PARAMETER name:max index:0 type:kotlin.Int + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .CounterConfig declared in .CounterConfig.copy' type=.CounterConfig origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (max: kotlin.Int): .CounterConfig declared in .CounterConfig' + CONSTRUCTOR_CALL 'public constructor (max: kotlin.Int) [primary] declared in .CounterConfig' type=.CounterConfig origin=null + max: GET_VAR 'max: kotlin.Int declared in .CounterConfig.copy' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.CounterConfig, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.CounterConfig + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .CounterConfig declared in .CounterConfig.equals' type=.CounterConfig origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .CounterConfig.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .CounterConfig' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.CounterConfig + GET_VAR 'other: kotlin.Any? declared in .CounterConfig.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .CounterConfig' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.CounterConfig [val] + TYPE_OP type=.CounterConfig origin=CAST typeOperand=.CounterConfig + GET_VAR 'other: kotlin.Any? declared in .CounterConfig.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .CounterConfig declared in .CounterConfig.equals' type=.CounterConfig origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_1: .CounterConfig [val] declared in .CounterConfig.equals' type=.CounterConfig origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .CounterConfig' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .CounterConfig' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.CounterConfig) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.CounterConfig + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .CounterConfig' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .CounterConfig declared in .CounterConfig.hashCode' type=.CounterConfig origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.CounterConfig) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.CounterConfig + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .CounterConfig' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="CounterConfig(" + CONST String type=kotlin.String value="max=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:max type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .CounterConfig declared in .CounterConfig.toString' type=.CounterConfig origin=null + CONST String type=kotlin.String value=")" + CLASS CLASS name:CounterIterator modality:FINAL visibility:public superTypes:[kotlin.collections.Iterator] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.CounterIterator + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.CounterConfig visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:.CounterConfig, counter:.Counter) returnType:.CounterIterator [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.CounterConfig + VALUE_PARAMETER name:counter index:1 type:.Counter + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:CounterIterator modality:FINAL visibility:public superTypes:[kotlin.collections.Iterator]' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.CounterConfig visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .CounterIterator declared in .CounterIterator' type=.CounterIterator origin=null + value: GET_VAR '_context_receiver_0: .CounterConfig declared in .CounterIterator.' type=.CounterConfig origin=null + PROPERTY name:counter visibility:private modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:counter type:.Counter visibility:private [final] + EXPRESSION_BODY + GET_VAR 'counter: .Counter declared in .CounterIterator.' type=.Counter origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:private modality:FINAL <> ($this:.CounterIterator) returnType:.Counter + correspondingProperty: PROPERTY name:counter visibility:private modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.CounterIterator + BLOCK_BODY + RETURN type=kotlin.Nothing from='private final fun (): .Counter declared in .CounterIterator' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:.Counter visibility:private [final]' type=.Counter origin=null + receiver: GET_VAR ': .CounterIterator declared in .CounterIterator.' type=.CounterIterator origin=null + FUN name:hasNext visibility:public modality:FINAL <> ($this:.CounterIterator) returnType:kotlin.Boolean [operator] + overridden: + public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER name: type:.CounterIterator + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun hasNext (): kotlin.Boolean [operator] declared in .CounterIterator' + CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun (): kotlin.Int declared in .Counter' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'private final fun (): .Counter declared in .CounterIterator' type=.Counter origin=GET_PROPERTY + $this: GET_VAR ': .CounterIterator declared in .CounterIterator.hasNext' type=.CounterIterator origin=null + arg1: CALL 'public final fun (): kotlin.Int declared in .CounterConfig' type=kotlin.Int origin=GET_PROPERTY + $this: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.CounterConfig visibility:private [final]' type=.CounterConfig origin=null + receiver: GET_VAR ': .CounterIterator declared in .CounterIterator.hasNext' type=.CounterIterator origin=null + FUN name:next visibility:public modality:FINAL <> ($this:.CounterIterator) returnType:kotlin.Int [operator] + overridden: + public abstract fun next (): T of kotlin.collections.Iterator [operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER name: type:.CounterIterator + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun next (): kotlin.Int [operator] declared in .CounterIterator' + BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Counter [val] + CALL 'private final fun (): .Counter declared in .CounterIterator' type=.Counter origin=GET_PROPERTY + $this: GET_VAR ': .CounterIterator declared in .CounterIterator.next' type=.CounterIterator origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CALL 'public final fun (): kotlin.Int declared in .Counter' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'val tmp_2: .Counter [val] declared in .CounterIterator.next' type=.Counter origin=null + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in .Counter' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val tmp_2: .Counter [val] declared in .CounterIterator.next' type=.Counter origin=null + : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .CounterIterator.next' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int [val] declared in .CounterIterator.next' type=kotlin.Int origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in kotlin.collections.Iterator + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:iterator visibility:public modality:FINAL <> ($receiver:.Counter, _context_receiver_0:.CounterConfig) returnType:.CounterIterator [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Counter + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.CounterConfig + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun iterator (_context_receiver_0: .CounterConfig): .CounterIterator [operator] declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=.CounterIterator origin=null + : .CounterConfig + : .CounterIterator + receiver: GET_VAR '_context_receiver_0: .CounterConfig declared in .iterator' type=.CounterConfig origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.CounterConfig, .CounterIterator> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.CounterConfig) returnType:.CounterIterator + $receiver: VALUE_PARAMETER name:$this$with type:.CounterConfig + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): .CounterIterator declared in .iterator' + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: .CounterConfig, counter: .Counter) [primary] declared in .CounterIterator' type=.CounterIterator origin=null + _context_receiver_0: GET_VAR '_context_receiver_0: .CounterConfig declared in .iterator' type=.CounterConfig origin=null + counter: GET_VAR ': .Counter declared in .iterator' type=.Counter origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:result type:kotlin.Int [var] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .CounterConfig + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor (max: kotlin.Int) [primary] declared in .CounterConfig' type=.CounterConfig origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.CounterConfig, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.CounterConfig) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.CounterConfig + BLOCK_BODY + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_4 type:.CounterIterator [val] + CALL 'public final fun iterator (_context_receiver_0: .CounterConfig): .CounterIterator [operator] declared in ' type=.CounterIterator origin=null + $receiver: CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Counter' type=.Counter origin=null + _context_receiver_0: GET_VAR '$this$with: .CounterConfig declared in .box.' type=.CounterConfig origin=null + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public final fun hasNext (): kotlin.Boolean [operator] declared in .CounterIterator' type=kotlin.Boolean origin=null + $this: GET_VAR 'val tmp_4: .CounterIterator [val] declared in .box.' type=.CounterIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int [operator] declared in .CounterIterator' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_4: .CounterIterator [val] declared in .box.' type=.CounterIterator origin=null + BLOCK type=kotlin.Unit origin=null + SET_VAR 'var result: kotlin.Int [var] declared in .box' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int [var] declared in .box' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int [val] declared in .box.' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + WHEN type=kotlin.String origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'var result: kotlin.Int [var] declared in .box' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=45 + then: CONST String type=kotlin.String value="OK" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.kt.txt new file mode 100644 index 00000000000..ffa4d46e02e --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.fir.kt.txt @@ -0,0 +1,141 @@ +data class Counter { + constructor(i: Int = 0) /* primary */ { + super/*Any*/() + /* () */ + + } + + var i: Int + field = i + get + set + + operator fun component1(): Int { + return .#i + } + + fun copy(i: Int = .#i): Counter { + return Counter(i = i) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is Counter -> return false + } + val tmp0_other_with_cast: Counter = other as Counter + when { + EQEQ(arg0 = .#i, arg1 = tmp0_other_with_cast.#i).not() -> return false + } + return true + } + + override fun hashCode(): Int { + return .#i.hashCode() + } + + override fun toString(): String { + return "Counter(" + "i=" + .#i + ")" + } + +} + +data class CounterConfig { + constructor(max: Int = 10) /* primary */ { + super/*Any*/() + /* () */ + + } + + val max: Int + field = max + get + + operator fun component1(): Int { + return .#max + } + + fun copy(max: Int = .#max): CounterConfig { + return CounterConfig(max = max) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is CounterConfig -> return false + } + val tmp0_other_with_cast: CounterConfig = other as CounterConfig + when { + EQEQ(arg0 = .#max, arg1 = tmp0_other_with_cast.#max).not() -> return false + } + return true + } + + override fun hashCode(): Int { + return .#max.hashCode() + } + + override fun toString(): String { + return "CounterConfig(" + "max=" + .#max + ")" + } + +} + +class CounterIterator : Iterator { + private /* final field */ val contextReceiverField0: CounterConfig + constructor(_context_receiver_0: CounterConfig, counter: Counter) /* primary */ { + super/*Any*/() + /* () */ + + .#contextReceiverField0 = _context_receiver_0 + } + + private val counter: Counter + field = counter + private get + + override operator fun hasNext(): Boolean { + return less(arg0 = .().(), arg1 = .#contextReceiverField0.()) + } + + override operator fun next(): Int { + return { // BLOCK + val : Counter = .() + val : Int = .() + .( = .inc()) + + } + } + +} + +operator fun Counter.iterator(_context_receiver_0: CounterConfig): CounterIterator { + return with(receiver = _context_receiver_0, block = local fun CounterConfig.(): CounterIterator { + return CounterIterator(_context_receiver_0 = _context_receiver_0, counter = ) + } +) +} + +fun box(): String { + var result: Int = 0 + with(receiver = CounterConfig(), block = local fun CounterConfig.() { + { // BLOCK + val : CounterIterator = Counter().iterator(_context_receiver_0 = $this$with) + while (.hasNext()) { // BLOCK + val i: Int = .next() + { // BLOCK + result = result.plus(other = i) + } + } + } + } +) + return when { + EQEQ(arg0 = result, arg1 = 45) -> "OK" + else -> "fail" + } +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt index 49390ed3dff..0a0f62aba1a 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR // WITH_STDLIB data class Counter(var i: Int = 0) @@ -25,4 +24,4 @@ fun box(): String { } } return if (result == 45) "OK" else "fail" -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.ir.txt new file mode 100644 index 00000000000..41c612c2a11 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.ir.txt @@ -0,0 +1,160 @@ +FILE fqName: fileName:/lazy.kt + CLASS INTERFACE name:Lazy modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Lazy.Lazy> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test1 visibility:public modality:FINAL <> (_context_receiver_0:.Lazy, _context_receiver_1:.Lazy) returnType:kotlin.Unit + contextReceiverParametersCount: 2 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Lazy + VALUE_PARAMETER name:_context_receiver_1 index:1 type:.Lazy + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL ($receiver:.Lazy, _context_receiver_0:.Lazy.test2>) returnType:kotlin.Unit + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Lazy + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Lazy.test2> + BLOCK_BODY + FUN name:test3 visibility:public modality:FINAL ($receiver:.Lazy, _context_receiver_0:.Lazy<.Lazy.test3>>) returnType:kotlin.Unit + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Lazy + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Lazy<.Lazy.test3>> + BLOCK_BODY + FUN name:f visibility:public modality:FINAL (lazy1:.Lazy, lazy2:.Lazy, lazyT:.Lazy.f>, lazyLazyT:.Lazy<.Lazy.f>>) returnType:kotlin.Unit + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + VALUE_PARAMETER name:lazy1 index:0 type:.Lazy + VALUE_PARAMETER name:lazy2 index:1 type:.Lazy + VALUE_PARAMETER name:lazyT index:2 type:.Lazy.f> + VALUE_PARAMETER name:lazyLazyT index:3 type:.Lazy<.Lazy.f>> + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .f' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy2: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test1 (_context_receiver_0: .Lazy, _context_receiver_1: .Lazy): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + _context_receiver_1: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + CALL 'public final fun test2 (_context_receiver_0: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.Int + $receiver: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy2: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .f' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test1 (_context_receiver_0: .Lazy, _context_receiver_1: .Lazy): kotlin.Unit declared in ' type=kotlin.Unit origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + _context_receiver_1: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + CALL 'public final fun test2 (_context_receiver_0: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.CharSequence + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy.f> + : kotlin.Unit + receiver: GET_VAR 'lazyT: .Lazy.f> declared in .f' type=.Lazy.f> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy.f>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy.f>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy.f> + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .f' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test2 (_context_receiver_0: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : T of .f + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy.f> declared in .f.' type=.Lazy.f> origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy<.Lazy.f>> + : kotlin.Unit + receiver: GET_VAR 'lazyLazyT: .Lazy<.Lazy.f>> declared in .f' type=.Lazy<.Lazy.f>> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy<.Lazy.f>>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy<.Lazy.f>>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy<.Lazy.f>> + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .f' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test2 (_context_receiver_0: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : .Lazy.f> + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy<.Lazy.f>> declared in .f.' type=.Lazy<.Lazy.f>> origin=null + CALL 'public final fun test3 (_context_receiver_0: .Lazy<.Lazy.test3>>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : T of .f + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy<.Lazy.f>> declared in .f.' type=.Lazy<.Lazy.f>> origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .f' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy<.Lazy.f>> + : kotlin.Unit + receiver: GET_VAR 'lazyLazyT: .Lazy<.Lazy.f>> declared in .f' type=.Lazy<.Lazy.f>> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy<.Lazy.f>>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy<.Lazy.f>>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy<.Lazy.f>> + BLOCK_BODY + CALL 'public final fun test2 (_context_receiver_0: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.Int + $receiver: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + CALL 'public final fun test3 (_context_receiver_0: .Lazy<.Lazy.test3>>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : T of .f + $receiver: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + _context_receiver_0: GET_VAR '$this$with: .Lazy<.Lazy.f>> declared in .f..' type=.Lazy<.Lazy.f>> origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.kt.txt new file mode 100644 index 00000000000..5570a801fe6 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.fir.kt.txt @@ -0,0 +1,54 @@ +interface Lazy { + +} + +fun test1(_context_receiver_0: Lazy, _context_receiver_1: Lazy) { +} + +fun Lazy.test2(_context_receiver_0: Lazy) { +} + +fun Lazy.test3(_context_receiver_0: Lazy>) { +} + +fun f(lazy1: Lazy, lazy2: Lazy, lazyT: Lazy, lazyLazyT: Lazy>) { + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + return with, Unit>(receiver = lazy2, block = local fun Lazy.() { + test1(_context_receiver_0 = $this$with, _context_receiver_1 = $this$with) + $this$with.test2(_context_receiver_0 = $this$with) + } +) + } +) + with, Unit>(receiver = lazy2, block = local fun Lazy.() { + return with, Unit>(receiver = lazy1, block = local fun Lazy.() { + test1(_context_receiver_0 = $this$with, _context_receiver_1 = $this$with) + $this$with.test2(_context_receiver_0 = $this$with) + } +) + } +) + with, Unit>(receiver = lazyT, block = local fun Lazy.() { + return with, Unit>(receiver = lazy1, block = local fun Lazy.() { + $this$with.test2(_context_receiver_0 = $this$with) + } +) + } +) + with>, Unit>(receiver = lazyLazyT, block = local fun Lazy>.() { + return with, Unit>(receiver = lazy1, block = local fun Lazy.() { + $this$with.test2>(_context_receiver_0 = $this$with) + $this$with.test3(_context_receiver_0 = $this$with) + } +) + } +) + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + return with>, Unit>(receiver = lazyLazyT, block = local fun Lazy>.() { + $this$with.test2(_context_receiver_0 = $this$with) + $this$with.test3(_context_receiver_0 = $this$with) + } +) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt index 0c0a9276f55..a82d4eeeea1 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR interface Lazy @@ -42,4 +41,4 @@ fun f(lazy1: Lazy, lazy2: Lazy, lazyT: Lazy, lazyLazyT test3() } } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.ir.txt new file mode 100644 index 00000000000..d3a5dc1ce19 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.ir.txt @@ -0,0 +1,45 @@ +FILE fqName: fileName:/overloadPriority.kt + CLASS CLASS name:Context modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Context + CONSTRUCTOR visibility:public <> () returnType:.Context [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Context modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL <> (_context_receiver_0:.Context) returnType:kotlin.String + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (_context_receiver_0: .Context): kotlin.String declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + FUN name:f visibility:public modality:FINAL <> () returnType:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (): kotlin.Any declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : .Context + : kotlin.Int + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Context' type=.Context origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Context, kotlin.Int> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Context) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:.Context + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test' + CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public final fun f (_context_receiver_0: .Context): kotlin.String declared in ' type=kotlin.String origin=null + _context_receiver_0: GET_VAR '$this$with: .Context declared in .test.' type=.Context origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.kt.txt new file mode 100644 index 00000000000..72c6f771651 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.fir.kt.txt @@ -0,0 +1,23 @@ +class Context { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +fun f(_context_receiver_0: Context): String { + return TODO() +} + +fun f(): Any { + return TODO() +} + +fun test() { + with(receiver = Context(), block = local fun Context.(): Int { + return f(_context_receiver_0 = $this$with).() + } +) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt index 46817fbe7ef..7bbeeaa485a 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR class Context @@ -12,4 +11,4 @@ fun test() { with(Context()) { f().length } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.ir.txt new file mode 100644 index 00000000000..00fb1e551b4 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.ir.txt @@ -0,0 +1,32 @@ +FILE fqName: fileName:/overloading.kt + FUN name:foo visibility:public modality:FINAL <> (_context_receiver_0:kotlin.Int, _context_receiver_1:kotlin.String) returnType:kotlin.Int + contextReceiverParametersCount: 2 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + VALUE_PARAMETER name:_context_receiver_1 index:1 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (_context_receiver_0: kotlin.Int, _context_receiver_1: kotlin.String): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR '_context_receiver_0: kotlin.Int declared in .foo' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=42 + FUN name:foo visibility:public modality:FINAL <> (_context_receiver_0:kotlin.Int) returnType:kotlin.Int + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (_context_receiver_0: kotlin.Int): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR '_context_receiver_0: kotlin.Int declared in .foo' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=42 + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : kotlin.Int + : kotlin.Int + receiver: CONST Int type=kotlin.Int value=42 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test' + CALL 'public final fun foo (_context_receiver_0: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .test.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.kt.txt new file mode 100644 index 00000000000..13fedc8cb2a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.fir.kt.txt @@ -0,0 +1,14 @@ +fun foo(_context_receiver_0: Int, _context_receiver_1: String): Int { + return _context_receiver_0.plus(other = 42) +} + +fun foo(_context_receiver_0: Int): Int { + return _context_receiver_0.plus(other = 42) +} + +fun test() { + with(receiver = 42, block = local fun Int.(): Int { + return foo(_context_receiver_0 = $this$with) + } +) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt index aa0ba29e6f8..d4eb6085eb1 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR context(Int, String) fun foo(): Int { @@ -15,4 +14,4 @@ fun test() { with(42) { foo() } -} \ No newline at end of file +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.ir.txt new file mode 100644 index 00000000000..cd3084c1fc9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.ir.txt @@ -0,0 +1,50 @@ +FILE fqName: fileName:/passingLambdaToContextualParam.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:result visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:result type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="OK" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.String + correspondingProperty: PROPERTY name:result visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:result type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:contextual visibility:public modality:FINAL <> (f:kotlin.Function1<.C, kotlin.String>) returnType:kotlin.String + VALUE_PARAMETER name:f index:0 type:kotlin.Function1<.C, kotlin.String> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun contextual (f: kotlin.Function1<.C, kotlin.String>): kotlin.String declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.String origin=INVOKE + $this: GET_VAR 'f: kotlin.Function1<.C, kotlin.String> declared in .contextual' type=kotlin.Function1<.C, kotlin.String> origin=VARIABLE_AS_FUNCTION + p1: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun contextual (f: kotlin.Function1<.C, kotlin.String>): kotlin.String declared in ' type=kotlin.String origin=null + f: FUN_EXPR type=kotlin.Function1<.C, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (_context_receiver_0:.C) returnType:kotlin.String + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (_context_receiver_0: .C): kotlin.String declared in .box' + CALL 'public final fun (): kotlin.String declared in .C' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .C declared in .box.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.kt.txt new file mode 100644 index 00000000000..94e9134e7b8 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.fir.kt.txt @@ -0,0 +1,23 @@ +class C { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val result: String + field = "OK" + get + +} + +fun contextual(f: Function1): String { + return f.invoke(p1 = C()) +} + +fun box(): String { + return contextual(f = local fun (_context_receiver_0: C): String { + return _context_receiver_0.() + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.kt b/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.kt index 4a8fc45080b..b05b8ff87ac 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/passingLambdaToContextualParam.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR class C { val result = "OK" @@ -8,4 +7,4 @@ class C { fun contextual(f: context(C) () -> String) = f(C()) -fun box(): String = contextual { result } \ No newline at end of file +fun box(): String = contextual { result } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt index 5e2659b3c16..56bf88c0e3e 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt @@ -37,11 +37,13 @@ FILE fqName: fileName:/plusMatrix.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:plus visibility:public modality:FINAL <> ($receiver:.Matrix, other:.Matrix) returnType:.Matrix + FUN name:plus visibility:public modality:FINAL <> ($receiver:.Matrix, _context_receiver_0:.NumberOperations, other:.Matrix) returnType:.Matrix + contextReceiverParametersCount: 1 $receiver: VALUE_PARAMETER name: type:.Matrix - VALUE_PARAMETER name:other index:0 type:.Matrix + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.NumberOperations + VALUE_PARAMETER name:other index:1 type:.Matrix BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun plus (other: .Matrix): .Matrix declared in ' + RETURN type=kotlin.Nothing from='public final fun plus (_context_receiver_0: .NumberOperations, other: .Matrix): .Matrix declared in ' CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null FUN name:plusMatrix visibility:public modality:FINAL <> ($receiver:.NumberOperations, m1:.Matrix, m2:.Matrix) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.NumberOperations @@ -49,10 +51,12 @@ FILE fqName: fileName:/plusMatrix.kt VALUE_PARAMETER name:m2 index:1 type:.Matrix BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun plus (other: .Matrix): .Matrix declared in ' type=.Matrix origin=null + CALL 'public final fun plus (_context_receiver_0: .NumberOperations, other: .Matrix): .Matrix declared in ' type=.Matrix origin=null $receiver: GET_VAR 'm1: .Matrix declared in .plusMatrix' type=.Matrix origin=null + _context_receiver_0: GET_VAR ': .NumberOperations declared in .plusMatrix' type=.NumberOperations origin=null other: GET_VAR 'm2: .Matrix declared in .plusMatrix' type=.Matrix origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun plus (other: .Matrix): .Matrix declared in ' type=.Matrix origin=null + CALL 'public final fun plus (_context_receiver_0: .NumberOperations, other: .Matrix): .Matrix declared in ' type=.Matrix origin=null $receiver: GET_VAR 'm2: .Matrix declared in .plusMatrix' type=.Matrix origin=null + _context_receiver_0: GET_VAR ': .NumberOperations declared in .plusMatrix' type=.NumberOperations origin=null other: GET_VAR 'm1: .Matrix declared in .plusMatrix' type=.Matrix origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt index 42c9efc2f8d..0659c7954d3 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt @@ -12,11 +12,11 @@ class Matrix { } -fun Matrix.plus(other: Matrix): Matrix { +fun Matrix.plus(_context_receiver_0: NumberOperations, other: Matrix): Matrix { return TODO() } fun NumberOperations.plusMatrix(m1: Matrix, m2: Matrix) { - m1.plus(other = m2) /*~> Unit */ - m2.plus(other = m1) /*~> Unit */ + m1.plus(_context_receiver_0 = , other = m2) /*~> Unit */ + m2.plus(_context_receiver_0 = , other = m1) /*~> Unit */ } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/property.fir.ir.txt new file mode 100644 index 00000000000..e63f68564e6 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.fir.ir.txt @@ -0,0 +1,48 @@ +FILE fqName: fileName:/property.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:a visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.A + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:b visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.B + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:c visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> (_context_receiver_0:.A, _context_receiver_1:.B) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + contextReceiverParametersCount: 2 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.A + VALUE_PARAMETER name:_context_receiver_1 index:1 type:.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (_context_receiver_0: .A, _context_receiver_1: .B): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public abstract fun a (): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_0: .A declared in .' type=.A origin=null + other: CALL 'public abstract fun b (): kotlin.Int declared in .B' type=kotlin.Int origin=null + $this: GET_VAR '_context_receiver_1: .B declared in .' type=.B origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/property.fir.kt.txt new file mode 100644 index 00000000000..cef4e06e00d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.fir.kt.txt @@ -0,0 +1,14 @@ +interface A { + abstract fun a(): Int + +} + +interface B { + abstract fun b(): Int + +} + +val c: Int + get(_context_receiver_0: A, _context_receiver_1: B): Int { + return _context_receiver_0.a().plus(other = _context_receiver_1.b()) + } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.kt b/compiler/testData/ir/irText/declarations/contextReceivers/property.kt index cde08f9b377..cfebc731f0a 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/property.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR interface A { fun a(): Int @@ -9,4 +8,4 @@ interface B { } context(A, B) -val c get() = a() + b() \ No newline at end of file +val c get() = a() + b() diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.ir.txt new file mode 100644 index 00000000000..082b9a55bca --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.ir.txt @@ -0,0 +1,143 @@ +FILE fqName: fileName:/thisWithCustomLabel.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.A> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false + CONSTRUCTOR visibility:public <> (a:T of .A) returnType:.A.A> [primary] + VALUE_PARAMETER name:a index:0 type:T of .A + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:a visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:a type:T of .A visibility:private [final] + EXPRESSION_BODY + GET_VAR 'a: T of .A declared in .A.' type=T of .A origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A.A>) returnType:T of .A + correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.A.A> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of .A declared in .A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:T of .A visibility:private [final]' type=T of .A origin=null + receiver: GET_VAR ': .A.A> declared in .A.' type=.A.A> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + CONSTRUCTOR visibility:public <> (b:kotlin.Any) returnType:.B [primary] + VALUE_PARAMETER name:b index:0 type:kotlin.Any + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:b visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Any visibility:private [final] + EXPRESSION_BODY + GET_VAR 'b: kotlin.Any declared in .B.' type=kotlin.Any origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.B) returnType:kotlin.Any + correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .B' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + receiver: GET_VAR ': .B declared in .B.' type=.B origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (c:kotlin.Any) returnType:.C [primary] + VALUE_PARAMETER name:c index:0 type:kotlin.Any + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Any visibility:private [final] + EXPRESSION_BODY + GET_VAR 'c: kotlin.Any declared in .C.' type=kotlin.Any origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Any + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL <> (_context_receiver_0:.A, _context_receiver_1:.A, _context_receiver_2:.B) returnType:kotlin.Unit + contextReceiverParametersCount: 3 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.A + VALUE_PARAMETER name:_context_receiver_1 index:1 type:.A + VALUE_PARAMETER name:_context_receiver_2 index:2 type:.B + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun toFloat (): kotlin.Float declared in kotlin.Int' type=kotlin.Float origin=null + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .A declared in .f' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_1: .A declared in .f' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_2: .B declared in .f' type=.B origin=null + PROPERTY name:p visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($receiver:.C, _context_receiver_0:.A, _context_receiver_1:.A, _context_receiver_2:.B) returnType:kotlin.Int + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [val] + contextReceiverParametersCount: 3 + $receiver: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.A + VALUE_PARAMETER name:_context_receiver_1 index:1 type:.A + VALUE_PARAMETER name:_context_receiver_2 index:2 type:.B + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun toFloat (): kotlin.Float declared in kotlin.Int' type=kotlin.Float origin=null + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_0: .A declared in .' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_1: .A declared in .' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR '_context_receiver_2: .B declared in .' type=.B origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .C' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .' type=.C origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .C' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .' type=.C origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .C' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .' type=.C origin=null + RETURN type=kotlin.Nothing from='public final fun (_context_receiver_0: .A, _context_receiver_1: .A, _context_receiver_2: .B): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.kt.txt new file mode 100644 index 00000000000..37acd8f8ebf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.fir.kt.txt @@ -0,0 +1,55 @@ +class A { + constructor(a: T) /* primary */ { + super/*Any*/() + /* () */ + + } + + val a: T + field = a + get + +} + +class B { + constructor(b: Any) /* primary */ { + super/*Any*/() + /* () */ + + } + + val b: Any + field = b + get + +} + +class C { + constructor(c: Any) /* primary */ { + super/*Any*/() + /* () */ + + } + + val c: Any + field = c + get + +} + +fun f(_context_receiver_0: A, _context_receiver_1: A, _context_receiver_2: B) { + _context_receiver_0.().toFloat() /*~> Unit */ + _context_receiver_1.().() /*~> Unit */ + _context_receiver_2.() /*~> Unit */ +} + +val C.p: Int + get(_context_receiver_0: A, _context_receiver_1: A, _context_receiver_2: B): Int { + _context_receiver_0.().toFloat() /*~> Unit */ + _context_receiver_1.().() /*~> Unit */ + _context_receiver_2.() /*~> Unit */ + .() /*~> Unit */ + .() /*~> Unit */ + .() /*~> Unit */ + return 1 + } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt index 9ae178123e7..d5f4df19fc7 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt @@ -1,5 +1,4 @@ // !LANGUAGE: +ContextReceivers -// IGNORE_BACKEND_FIR: JVM_IR class A(val a: T) class B(val b: Any) @@ -20,4 +19,4 @@ context(labelAInt@A, A, labelB@B) val C.p: Int this@p.c this.c return 1 - } \ No newline at end of file + } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.ir.txt index 1a52bd7361e..a87bb46109f 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.ir.txt @@ -1,7 +1,9 @@ FILE fqName: fileName:/typeParameterAsContextReceiver.kt - FUN name:useContext visibility:public modality:FINAL (block:kotlin.Function1.useContext, kotlin.Unit>) returnType:kotlin.Unit + FUN name:useContext visibility:public modality:FINAL (_context_receiver_0:T of .useContext, block:kotlin.Function1.useContext, kotlin.Unit>) returnType:kotlin.Unit TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false - VALUE_PARAMETER name:block index:0 type:kotlin.Function1.useContext, kotlin.Unit> + contextReceiverParametersCount: 1 + VALUE_PARAMETER name:_context_receiver_0 index:0 type:T of .useContext + VALUE_PARAMETER name:block index:1 type:kotlin.Function1.useContext, kotlin.Unit> BLOCK_BODY FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY @@ -13,8 +15,9 @@ FILE fqName: fileName:/typeParameterAsContextReceiver.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int BLOCK_BODY - CALL 'public final fun useContext (block: kotlin.Function1.useContext, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + CALL 'public final fun useContext (_context_receiver_0: T of .useContext, block: kotlin.Function1.useContext, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null : kotlin.Int + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .test.' type=kotlin.Int origin=null block: FUN_EXPR type=kotlin.Function1 origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (i:kotlin.Int) returnType:kotlin.Unit VALUE_PARAMETER name:i index:0 type:kotlin.Int diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.kt.txt index 25114176766..dd0bd6806f8 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/typeParameterAsContextReceiver.fir.kt.txt @@ -1,9 +1,9 @@ -fun useContext(block: Function1) { +fun useContext(_context_receiver_0: T, block: Function1) { } fun test() { with(receiver = 42, block = local fun Int.() { - useContext(block = local fun (i: Int) { + useContext(_context_receiver_0 = $this$with, block = local fun (i: Int) { i.toDouble() /*~> Unit */ } ) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt new file mode 100644 index 00000000000..85e407df362 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.ir.txt @@ -0,0 +1,238 @@ +FILE fqName: fileName:/unaryOperators.kt + CLASS CLASS name:Result modality:FINAL visibility:public [data] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Result + CONSTRUCTOR visibility:public <> (i:kotlin.Int) returnType:.Result [primary] + VALUE_PARAMETER name:i index:0 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Result modality:FINAL visibility:public [data] superTypes:[kotlin.Any]' + PROPERTY name:i visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'i: kotlin.Int declared in .Result.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Result) returnType:kotlin.Int + correspondingProperty: PROPERTY name:i visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Result' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.' type=.Result origin=null + FUN name:component1 visibility:public modality:FINAL <> ($this:.Result) returnType:kotlin.Int [operator] + $this: VALUE_PARAMETER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int [operator] declared in .Result' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.component1' type=.Result origin=null + FUN name:copy visibility:public modality:FINAL <> ($this:.Result, i:kotlin.Int) returnType:.Result + $this: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:i index:0 type:kotlin.Int + EXPRESSION_BODY + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.copy' type=.Result origin=null + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun copy (i: kotlin.Int): .Result declared in .Result' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: GET_VAR 'i: kotlin.Int declared in .Result.copy' type=kotlin.Int origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:equals visibility:public modality:OPEN <> ($this:.Result, other:kotlin.Any?) returnType:kotlin.Boolean + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Result + VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name:other index:0 type:kotlin.Any? + BLOCK_BODY + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun EQEQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQEQ + arg0: GET_VAR ': .Result declared in .Result.equals' type=.Result origin=null + arg1: GET_VAR 'other: kotlin.Any? declared in .Result.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=true + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP type=kotlin.Boolean origin=NOT_INSTANCEOF typeOperand=.Result + GET_VAR 'other: kotlin.Any? declared in .Result.equals' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=false + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Result [val] + TYPE_OP type=.Result origin=CAST typeOperand=.Result + GET_VAR 'other: kotlin.Any? declared in .Result.equals' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.equals' type=.Result origin=null + arg1: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR 'val tmp_0: .Result [val] declared in .Result.equals' type=.Result origin=null + then: RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=false + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in .Result' + CONST Boolean type=kotlin.Boolean value=true + FUN GENERATED_DATA_CLASS_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.Result) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .Result' + CALL 'public open fun hashCode (): kotlin.Int [fake_override] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.hashCode' type=.Result origin=null + FUN GENERATED_DATA_CLASS_MEMBER name:toString visibility:public modality:OPEN <> ($this:.Result) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER GENERATED_DATA_CLASS_MEMBER name: type:.Result + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .Result' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Result(" + CONST String type=kotlin.String value="i=" + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Result declared in .Result.toString' type=.Result origin=null + CONST String type=kotlin.String value=")" + PROPERTY name:operationScore visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Int origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:operationScore visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:operationScore type:kotlin.Int visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + FUN name:unaryMinus visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .unaryMinus' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun unaryMinus (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun unaryMinus (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .unaryMinus' type=.Result origin=null + FUN name:unaryPlus visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .unaryPlus' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun unaryPlus (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: WHEN type=kotlin.Int origin=IF + BRANCH + if: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .unaryPlus' type=.Result origin=null + arg1: CONST Int type=kotlin.Int value=0 + then: CALL 'public final fun unaryMinus (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .unaryPlus' type=.Result origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .unaryPlus' type=.Result origin=null + FUN name:inc visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .inc' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .inc' type=.Result origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:dec visibility:public modality:FINAL <> ($receiver:.Result, _context_receiver_0:kotlin.Int) returnType:.Result [operator] + contextReceiverParametersCount: 1 + $receiver: VALUE_PARAMETER name: type:.Result + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Int + BLOCK_BODY + CALL 'public final fun (: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + other: GET_VAR '_context_receiver_0: kotlin.Int declared in .dec' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun dec (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS + $this: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .Result declared in .dec' type=.Result origin=null + other: CONST Int type=kotlin.Int value=1 + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:result type:.Result [var] + CONSTRUCTOR_CALL 'public constructor (i: kotlin.Int) [primary] declared in .Result' type=.Result origin=null + i: CONST Int type=kotlin.Int value=0 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=.Result origin=null + : kotlin.Int + : .Result + receiver: CONST Int type=kotlin.Int value=1 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1.Result> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:.Result + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Result [val] + GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'val tmp_1: .Result [val] declared in .box.' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + GET_VAR 'val tmp_1: .Result [val] declared in .box.' type=.Result origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Result [val] + GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'val tmp_2: .Result [val] declared in .box.' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + GET_VAR 'val tmp_2: .Result [val] declared in .box.' type=.Result origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun unaryMinus (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun unaryPlus (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:.Result [val] + GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + SET_VAR 'var result: .Result [var] declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun dec (_context_receiver_0: kotlin.Int): .Result [operator] declared in ' type=.Result origin=null + $receiver: GET_VAR 'val tmp_3: .Result [val] declared in .box.' type=.Result origin=null + _context_receiver_0: GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='local final fun (): .Result declared in .box' + GET_VAR 'val tmp_3: .Result [val] declared in .box.' type=.Result origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + WHEN type=kotlin.String origin=IF + BRANCH + if: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in .Result' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'var result: .Result [var] declared in .box' type=.Result origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + arg1: CONST Int type=kotlin.Int value=5 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false + then: CONST String type=kotlin.String value="OK" + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt new file mode 100644 index 00000000000..73e86e1ff3c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.fir.kt.txt @@ -0,0 +1,95 @@ +data class Result { + constructor(i: Int) /* primary */ { + super/*Any*/() + /* () */ + + } + + val i: Int + field = i + get + + operator fun component1(): Int { + return .#i + } + + fun copy(i: Int = .#i): Result { + return Result(i = i) + } + + override fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is Result -> return false + } + val tmp0_other_with_cast: Result = other as Result + when { + EQEQ(arg0 = .#i, arg1 = tmp0_other_with_cast.#i).not() -> return false + } + return true + } + + override fun hashCode(): Int { + return .#i.hashCode() + } + + override fun toString(): String { + return "Result(" + "i=" + .#i + ")" + } + +} + +var operationScore: Int + field = 0 + get + set + +operator fun Result.unaryMinus(_context_receiver_0: Int): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().unaryMinus()) +} + +operator fun Result.unaryPlus(_context_receiver_0: Int): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = when { + less(arg0 = .(), arg1 = 0) -> .().unaryMinus() + else -> .() + }) +} + +operator fun Result.inc(_context_receiver_0: Int): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().plus(other = 1)) +} + +operator fun Result.dec(_context_receiver_0: Int): Result { + ( = ().plus(other = _context_receiver_0)) + return Result(i = .().minus(other = 1)) +} + +fun box(): String { + var result: Result = Result(i = 0) + with(receiver = 1, block = local fun Int.(): Result { + val : Result = result + result = .inc(_context_receiver_0 = $this$with) + /*~> Unit */ + val : Result = result + result = .inc(_context_receiver_0 = $this$with) + /*~> Unit */ + result.unaryMinus(_context_receiver_0 = $this$with) /*~> Unit */ + result.unaryPlus(_context_receiver_0 = $this$with) /*~> Unit */ + val : Result = result + result = .dec(_context_receiver_0 = $this$with) + return + } +) /*~> Unit */ + return when { + when { + EQEQ(arg0 = result.(), arg1 = 1) -> EQEQ(arg0 = (), arg1 = 5) + else -> false + } -> "OK" + else -> "fail" + } +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.kt b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.kt index 3615e5a32dd..99f1f239236 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/unaryOperators.kt @@ -1,6 +1,5 @@ // !LANGUAGE: +ContextReceivers // TARGET_BACKEND: JVM_IR -// IGNORE_BACKEND_FIR: JVM_IR data class Result(val i: Int)