diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1667ca81fb2..4ac21a44409 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -15946,6 +15946,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/extensionClasses/constructors.kt"); } + @Test + @TestMetadata("contextualPrimaryConstructorWithParams.kt") + public void testContextualPrimaryConstructorWithParams() throws Exception { + runTest("compiler/testData/codegen/box/extensionClasses/contextualPrimaryConstructorWithParams.kt"); + } + @Test @TestMetadata("edouble.kt") public void testEdouble() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 2919441a995..9a799428b02 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -757,6 +757,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/declarations/contextReceivers/class.kt"); } + @Test + @TestMetadata("contextualPrimaryConstructorWithParams.kt") + public void testContextualPrimaryConstructorWithParams() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt"); + } + @Test @TestMetadata("function.kt") public void testFunction() throws Exception { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index cb2a9b0eec7..6ccfad15cec 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -474,7 +474,7 @@ class ClassGenerator( } ktPrimaryConstructor.valueParameters.forEachIndexed { i, ktParameter -> - val irValueParameter = irPrimaryConstructor.valueParameters[i] + val irValueParameter = irPrimaryConstructor.valueParameters[i + ktClassOrObject.contextReceivers.size] if (ktParameter.hasValOrVar()) { val irProperty = PropertyGenerator(declarationGenerator) .generatePropertyForPrimaryConstructorParameter(ktParameter, irValueParameter) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt index e6d317a4468..66f317b8fd1 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt @@ -156,7 +156,8 @@ internal class InsertImplicitCasts( return expression.transformPostfix { transformReceiverArguments(substitutedDescriptor) for (index in substitutedDescriptor.valueParameters.indices) { - val argument = getValueArgument(index) ?: continue + val irIndex = index + substitutedDescriptor.contextReceiverParameters.size + val argument = getValueArgument(irIndex) ?: continue val parameterType = substitutedDescriptor.valueParameters[index].type val originalParameterType = substitutedDescriptor.original.valueParameters[index].type @@ -168,7 +169,7 @@ internal class InsertImplicitCasts( else parameterType - putValueArgument(index, argument.cast(expectedType, originalExpectedType = originalParameterType)) + putValueArgument(irIndex, argument.cast(expectedType, originalExpectedType = originalParameterType)) } } } diff --git a/compiler/testData/codegen/box/extensionClasses/contextualPrimaryConstructorWithParams.kt b/compiler/testData/codegen/box/extensionClasses/contextualPrimaryConstructorWithParams.kt new file mode 100644 index 00000000000..2f9cd564532 --- /dev/null +++ b/compiler/testData/codegen/box/extensionClasses/contextualPrimaryConstructorWithParams.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR + +class O(val o: String) + +context(O) +class OK(val k: String) { + val result: String = o + k +} + +fun box(): String { + return with(O("O")) { + val ok = OK("K") + ok.result + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.ir.txt new file mode 100644 index 00000000000..7b2a9c30d33 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.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 <> (:.O, k:kotlin.String) returnType:.OK [primary] + VALUE_PARAMETER name: 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' + 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 ': .O declared in .OK.' type=.O origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:OK 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 + 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 (: .O, k: kotlin.String) [primary] declared in .OK' type=.OK origin=null + : 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.kt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt new file mode 100644 index 00000000000..f7ab50bc6af --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt @@ -0,0 +1,16 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +class O(val o: String) + +context(O) +class OK(val k: String) { + val result: String = o + k +} + +fun box(): String { + return with(O("O")) { + val ok = OK("K") + ok.result + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt.txt new file mode 100644 index 00000000000..c52fa7a0802 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.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(: O, k: String) /* primary */ { + super/*Any*/() + .#contextReceiverField0 = + /* () */ + + } + + 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( = $this$with, k = "K") + return ok.() + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt index 3d61c9a6bb9..97530819c78 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt @@ -183,8 +183,7 @@ FILE fqName: fileName:/compareTo.kt : 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 - : TYPE_OP type=T of . origin=IMPLICIT_CAST typeOperand=T of . - GET_VAR ': java.util.Comparator.>{ kotlin.TypeAliasesKt.Comparator.> } declared in .' type=java.util.Comparator.>{ kotlin.TypeAliasesKt.Comparator.> } origin=null + : GET_VAR ': java.util.Comparator.>{ kotlin.TypeAliasesKt.Comparator.> } declared in .' type=java.util.Comparator.>{ kotlin.TypeAliasesKt.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 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt index 245719306f7..fc750cb664f 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt @@ -67,7 +67,7 @@ infix operator fun T.compareTo(: Comparator, other: T): Int val Pair.min: T get(: Comparator): T { return when { - less(arg0 = .().compareTo( = /*as T */, other = .()), arg1 = 0) -> .() + less(arg0 = .().compareTo( = , other = .()), arg1 = 0) -> .() else -> .() } } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.txt deleted file mode 100644 index 3d61c9a6bb9..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.txt +++ /dev/null @@ -1,247 +0,0 @@ -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?] - TYPE_PARAMETER name:B index:1 variance: superTypes:[kotlin.Any?] - 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 GENERATED_DATA_CLASS_MEMBER 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 GENERATED_DATA_CLASS_MEMBER 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 GENERATED_DATA_CLASS_MEMBER 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 - : A of .Pair - : B of .Pair - 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: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 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 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 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:equals visibility:public modality:OPEN <> ($this:.Pair.Pair, B of .Pair>, other:kotlin.Any?) returnType:kotlin.Boolean [operator] - overridden: - public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any - $this: VALUE_PARAMETER name: type:.Pair.Pair, B of .Pair> - VALUE_PARAMETER 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 [operator] 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 [operator] 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 [operator] 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 [operator] declared in .Pair' - CONST Boolean type=kotlin.Boolean value=false - RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .Pair' - CONST Boolean type=kotlin.Boolean value=true - FUN name:compareTo visibility:public modality:FINAL ($receiver:T of .compareTo, :java.util.Comparator.compareTo>{ kotlin.TypeAliasesKt.Comparator.compareTo> }, other:T of .compareTo) returnType:kotlin.Int [operator,infix] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - $receiver: VALUE_PARAMETER name: type:T of .compareTo - VALUE_PARAMETER name: index:0 type:java.util.Comparator.compareTo>{ kotlin.TypeAliasesKt.Comparator.compareTo> } - VALUE_PARAMETER name:other index:1 type:T of .compareTo - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun compareTo (: java.util.Comparator.compareTo>{ kotlin.TypeAliasesKt.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 ': java.util.Comparator.compareTo>{ kotlin.TypeAliasesKt.Comparator.compareTo> } declared in .compareTo' type=java.util.Comparator.compareTo>{ kotlin.TypeAliasesKt.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 .>, :java.util.Comparator.>{ kotlin.TypeAliasesKt.Comparator.> }) returnType:T of . - correspondingProperty: PROPERTY name:min visibility:public modality:FINAL [val] - TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] - $receiver: VALUE_PARAMETER name: type:.Pair., T of .> - VALUE_PARAMETER name: index:0 type:java.util.Comparator.>{ kotlin.TypeAliasesKt.Comparator.> } - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (: java.util.Comparator.>{ kotlin.TypeAliasesKt.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 (: java.util.Comparator.compareTo>{ kotlin.TypeAliasesKt.Comparator.compareTo> }, other: T of .compareTo): kotlin.Int [operator,infix] declared in ' type=kotlin.Int origin=LT - : 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 - : TYPE_OP type=T of . origin=IMPLICIT_CAST typeOperand=T of . - GET_VAR ': java.util.Comparator.>{ kotlin.TypeAliasesKt.Comparator.> } declared in .' type=java.util.Comparator.>{ kotlin.TypeAliasesKt.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 [val] - TYPE_OP type=java.util.Comparator origin=SAM_CONVERSION typeOperand=java.util.Comparator - 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: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - 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: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String - 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 - : kotlin.String - receiver: GET_VAR 'val comparator: java.util.Comparator [val] declared in .box' type=java.util.Comparator 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) returnType:kotlin.String - $receiver: VALUE_PARAMETER name:$this$with type:java.util.Comparator - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' - CALL 'public final fun (: java.util.Comparator.>{ kotlin.TypeAliasesKt.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" - : GET_VAR '$this$with: java.util.Comparator declared in .box.' type=java.util.Comparator origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt index d7826db9cab..bda28b94dd5 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt @@ -105,8 +105,7 @@ FILE fqName: fileName:/functionalType.kt CALL 'public final fun f (: .O, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] 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 - : TYPE_OP type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, kotlin.String> origin=IMPLICIT_CAST typeOperand=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, kotlin.String> - GET_VAR '$this$with: .O declared in .box.' type=.O origin=null + : GET_VAR '$this$with: .O declared in .box.' type=.O origin=null g: FUN_EXPR type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, kotlin.String> origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.K, :.O, it:.Param) returnType:kotlin.String $receiver: VALUE_PARAMETER name:$this$f type:.K diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt index d45d2e63895..209941c1486 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt @@ -39,7 +39,7 @@ fun K.f(: O, g: @ExtensionFunctionType @ContextFunctionTypePara fun box(): String { return with(receiver = O(), block = local fun O.(): String { - return K().f( = $this$with /*as @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3 */, g = local fun K.(: O, it: Param): String { + return K().f( = $this$with, g = local fun K.(: O, it: Param): String { return $this$with.().plus(other = $this$f.()) } ) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt index f2d8dd0f622..042d2439a36 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt @@ -174,13 +174,11 @@ FILE fqName: fileName:/functionalType.kt BLOCK_BODY CALL 'public final fun f1 (: .C, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] 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 - : TYPE_OP type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: GET_VAR 'val lf1: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> [val] declared in .test' type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=null CALL 'public final fun f1 (: .C, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] 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 - : TYPE_OP type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: FUN_EXPR type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R, :.C, $noName_0:.Param) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name:$this$f1 type:.R @@ -194,12 +192,10 @@ FILE fqName: fileName:/functionalType.kt 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 (: .C, g: @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - : TYPE_OP type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: GET_VAR 'val lf2: @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> [val] declared in .test' type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> origin=null CALL 'public final fun f2 (: .C, g: @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - : TYPE_OP type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: FUN_EXPR type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (:.C, $noName_0:.Param) returnType:kotlin.Unit VALUE_PARAMETER name: index:0 type:.C @@ -210,13 +206,11 @@ FILE fqName: fileName:/functionalType.kt $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null CALL 'public final fun f3 (: .C, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] 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 - : TYPE_OP type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: GET_VAR 'val lf3: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> [val] declared in .test' type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> origin=null CALL 'public final fun f3 (: .C, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] 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 - : TYPE_OP type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: FUN_EXPR type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R, :.C) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name:$this$f3 type:.R @@ -229,12 +223,10 @@ FILE fqName: fileName:/functionalType.kt 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 (: .C, g: @[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - : TYPE_OP type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: GET_VAR 'val lf4: @[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> [val] declared in .test' type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> origin=null CALL 'public final fun f4 (: .C, g: @[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - : TYPE_OP type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> origin=IMPLICIT_CAST typeOperand=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> - GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + : GET_VAR '$this$with: .C declared in .test.' type=.C origin=null g: FUN_EXPR type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (:.C) returnType:kotlin.Unit VALUE_PARAMETER name: index:0 type:.C diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt index 2ab5782ce7a..00097c65620 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt @@ -70,25 +70,25 @@ fun test() { with(receiver = C(), block = local fun C.() { with(receiver = R(), block = local fun R.() { - $this$with.f1( = $this$with /*as @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3 */, g = lf1) - $this$with.f1( = $this$with /*as @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3 */, g = local fun R.(: C, $noName_0: Param) { + $this$with.f1( = $this$with, g = lf1) + $this$with.f1( = $this$with, g = local fun R.(: C, $noName_0: Param) { $this$f1.() /*~> Unit */ $this$with.() /*~> Unit */ } ) - f2( = $this$with /*as @ContextFunctionTypeParams(count = 1) Function2 */, g = lf2) - f2( = $this$with /*as @ContextFunctionTypeParams(count = 1) Function2 */, g = local fun (: C, $noName_0: Param) { + f2( = $this$with, g = lf2) + f2( = $this$with, g = local fun (: C, $noName_0: Param) { $this$with.() /*~> Unit */ } ) - $this$with.f3( = $this$with /*as @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function2 */, g = lf3) - $this$with.f3( = $this$with /*as @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function2 */, g = local fun R.(: C) { + $this$with.f3( = $this$with, g = lf3) + $this$with.f3( = $this$with, g = local fun R.(: C) { $this$f3.() /*~> Unit */ $this$with.() /*~> Unit */ } ) - f4( = $this$with /*as @ContextFunctionTypeParams(count = 1) Function1 */, g = lf4) - f4( = $this$with /*as @ContextFunctionTypeParams(count = 1) Function1 */, g = local fun (: C) { + f4( = $this$with, g = lf4) + f4( = $this$with, g = local fun (: C) { $this$with.() /*~> Unit */ } ) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt index deac4bfb978..5d990cd27bb 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt @@ -52,12 +52,10 @@ FILE fqName: fileName:/plusMatrix.kt TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun plus (: .NumberOperations, other: .Matrix): .Matrix declared in ' type=.Matrix origin=null $receiver: GET_VAR 'm1: .Matrix declared in .plusMatrix' type=.Matrix origin=null - : TYPE_OP type=.Matrix origin=IMPLICIT_CAST typeOperand=.Matrix - GET_VAR ': .NumberOperations declared in .plusMatrix' type=.NumberOperations origin=null + : 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 (: .NumberOperations, other: .Matrix): .Matrix declared in ' type=.Matrix origin=null $receiver: GET_VAR 'm2: .Matrix declared in .plusMatrix' type=.Matrix origin=null - : TYPE_OP type=.Matrix origin=IMPLICIT_CAST typeOperand=.Matrix - GET_VAR ': .NumberOperations declared in .plusMatrix' type=.NumberOperations origin=null + : 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.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt.txt index 616755f8785..48abea1a7b2 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt.txt @@ -17,6 +17,6 @@ fun Matrix.plus(: NumberOperations, other: Matrix): Matrix { } fun NumberOperations.plusMatrix(m1: Matrix, m2: Matrix) { - m1.plus( = /*as Matrix */, other = m2) /*~> Unit */ - m2.plus( = /*as Matrix */, other = m1) /*~> Unit */ + m1.plus( = , other = m2) /*~> Unit */ + m2.plus( = , other = m1) /*~> Unit */ } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 06ec57afeb4..b80f728086f 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -15946,6 +15946,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/extensionClasses/constructors.kt"); } + @Test + @TestMetadata("contextualPrimaryConstructorWithParams.kt") + public void testContextualPrimaryConstructorWithParams() throws Exception { + runTest("compiler/testData/codegen/box/extensionClasses/contextualPrimaryConstructorWithParams.kt"); + } + @Test @TestMetadata("edouble.kt") public void testEdouble() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index fba43d92c10..ab769675e4d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -757,6 +757,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/declarations/contextReceivers/class.kt"); } + @Test + @TestMetadata("contextualPrimaryConstructorWithParams.kt") + public void testContextualPrimaryConstructorWithParams() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt"); + } + @Test @TestMetadata("function.kt") public void testFunction() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java index 4c9f71da362..884a5904b47 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java @@ -608,6 +608,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase { runTest("compiler/testData/ir/irText/declarations/contextReceivers/class.kt"); } + @TestMetadata("contextualPrimaryConstructorWithParams.kt") + public void testContextualPrimaryConstructorWithParams() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt"); + } + @TestMetadata("function.kt") public void testFunction() throws Exception { runTest("compiler/testData/ir/irText/declarations/contextReceivers/function.kt");