diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt index f1b444232de..58bf2a2d832 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt @@ -133,19 +133,13 @@ internal class ClassMemberGenerator( val thisParameter = conversionScope.dispatchReceiverParameter(irClass) ?: error("No found this parameter for $irClass") - val receiver = IrGetValueImpl( - UNDEFINED_OFFSET, UNDEFINED_OFFSET, - thisParameter.type, - thisParameter.symbol, - ) - for (index in containingClass.contextReceivers.indices) { val irValueParameter = valueParameters[index] body.statements.add( IrSetFieldImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, contextReceiverFields[index].symbol, - receiver, + IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, thisParameter.type, thisParameter.symbol), IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irValueParameter.type, irValueParameter.symbol), components.irBuiltIns.unitType, ) 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 df2c4e628a6..36da8d18cba 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 @@ -17215,6 +17215,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/extensionClasses/generics.kt"); } + @Test + @TestMetadata("multiple.kt") + public void testMultiple() throws Exception { + runTest("compiler/testData/codegen/box/extensionClasses/multiple.kt"); + } + @Test @TestMetadata("propertyWithContext.kt") public void testPropertyWithContext() 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 308ac1c7ddf..4a5a3ae9f9b 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 @@ -859,6 +859,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt"); } + @Test + @TestMetadata("kt52791.kt") + public void testKt52791() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt"); + } + @Test @TestMetadata("lazy.kt") public void testLazy() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java index 3278378f2f8..0ec56d2a047 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/LightTreeFir2IrTextTestGenerated.java @@ -859,6 +859,12 @@ public class LightTreeFir2IrTextTestGenerated extends AbstractLightTreeFir2IrTex runTest("compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt"); } + @Test + @TestMetadata("kt52791.kt") + public void testKt52791() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt"); + } + @Test @TestMetadata("lazy.kt") public void testLazy() throws Exception { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index c4d9d42e0b3..bf22e7dfa02 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -52,6 +52,7 @@ import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.IntStream; import static kotlin.collections.CollectionsKt.firstOrNull; import static org.jetbrains.kotlin.descriptors.DescriptorVisibilities.PRIVATE; @@ -310,17 +311,23 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return CollectionsKt.emptyList(); } List contextReceivers = classOrObject.getContextReceivers(); - List contextReceiverDescriptors = contextReceivers.stream() - .map(contextReceiver -> { + List contextReceiverDescriptors = + IntStream.range(0, contextReceivers.size()) + .mapToObj(index -> { + KtContextReceiver contextReceiver = contextReceivers.get(index); KtTypeReference typeReference = contextReceiver.typeReference(); if (typeReference == null) return null; KotlinType kotlinType = c.getTypeResolver().resolveType(getScopeForClassHeaderResolution(), typeReference, c.getTrace(), true); + Name label = contextReceiver.labelNameAsName() != null + ? contextReceiver.labelNameAsName() + : Name.identifier("_context_receiver_" + index); return DescriptorFactory.createContextReceiverParameterForClass( this, kotlinType, contextReceiver.labelNameAsName(), - Annotations.Companion.getEMPTY() + Annotations.Companion.getEMPTY(), + index ); }) .filter(Objects::nonNull) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt index d2f2298edb2..4b747989e3b 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt @@ -370,18 +370,18 @@ class BodyGenerator( irBlockBody: IrBlockBody ) { val thisAsReceiverParameter = classDescriptor.thisAsReceiverParameter - val receiver = IrGetValueImpl( - UNDEFINED_OFFSET, UNDEFINED_OFFSET, - thisAsReceiverParameter.type.toIrType(), - context.symbolTable.referenceValue(thisAsReceiverParameter) - ) for ((index, receiverDescriptor) in classDescriptor.contextReceivers.withIndex()) { val irValueParameter = irConstructor.valueParameters[index] irBlockBody.statements.add( IrSetFieldImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.additionalDescriptorStorage.getSyntheticField(receiverDescriptor.value).symbol, - receiver, + IrGetValueImpl( + UNDEFINED_OFFSET, + UNDEFINED_OFFSET, + thisAsReceiverParameter.type.toIrType(), + context.symbolTable.referenceValue(thisAsReceiverParameter) + ), IrGetValueImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, irValueParameter.type, irValueParameter.symbol), context.irBuiltIns.unitType ) diff --git a/compiler/testData/codegen/box/extensionClasses/multiple.kt b/compiler/testData/codegen/box/extensionClasses/multiple.kt new file mode 100644 index 00000000000..c9aacc3f6df --- /dev/null +++ b/compiler/testData/codegen/box/extensionClasses/multiple.kt @@ -0,0 +1,19 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR + +class A(val a: String) +class B(val b: String) + +context(A, B) +class C { + fun foo() = this@A.a + this@B.b +} + +fun box(): String { + val c = with(A("O")) { + with(B("K")) { + C() + } + } + return c.foo() +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt deleted file mode 100644 index 26252740552..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.ir.txt +++ /dev/null @@ -1,79 +0,0 @@ -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' - 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 - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inner modality:FINAL visibility:public superTypes:[kotlin.Any]' - 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 deleted file mode 100644 index af6f865267a..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/class.fir.kt.txt +++ /dev/null @@ -1,34 +0,0 @@ -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.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.ir.txt index ad2ea8af626..26252740552 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/class.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.ir.txt @@ -32,14 +32,14 @@ FILE fqName: fileName:/class.kt 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 <> (:.Outer, arg:kotlin.Any) returnType:.Inner [primary] - VALUE_PARAMETER name: index:0 type:.Outer + 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' 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 ': .Outer declared in .Inner.' type=.Outer origin=null + value: GET_VAR '_context_receiver_0: .Outer declared in .Inner.' type=.Outer origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inner modality:FINAL visibility:public superTypes:[kotlin.Any]' FUN name:bar visibility:public modality:FINAL <> ($this:.Inner) returnType:kotlin.Int $this: VALUE_PARAMETER name: type:.Inner @@ -74,6 +74,6 @@ FILE fqName: fileName:/class.kt $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 (: .Outer, arg: kotlin.Any) [primary] declared in .Inner' type=.Inner origin=null - : GET_VAR '$this$with: .Outer declared in .f.' type=.Outer origin=null + 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.kt b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt index 53346915b6f..0a89feedd9a 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/class.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ContextReceivers class Outer { diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt index 0bfc1050624..af6f865267a 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt @@ -13,9 +13,9 @@ class Outer { class Inner { private /* final field */ val contextReceiverField0: Outer - constructor(: Outer, arg: Any) /* primary */ { + constructor(_context_receiver_0: Outer, arg: Any) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } @@ -28,7 +28,7 @@ class Inner { fun f(outer: Outer) { with(receiver = outer, block = local fun Outer.(): Inner { - return Inner( = $this$with, arg = 3) + return Inner(_context_receiver_0 = $this$with, arg = 3) } ) /*~> Unit */ } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.fir.ir.txt deleted file mode 100644 index 7c2160bbf44..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.fir.ir.txt +++ /dev/null @@ -1,61 +0,0 @@ -FILE fqName: fileName:/contextReceiverMethod.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:foo 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 foo (): 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 - CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any] - $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test - FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Context visibility:private [final] - CONSTRUCTOR visibility:public <> (_context_receiver_0:.Context) returnType:.Test [primary] - VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context - BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' - SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Context visibility:private [final]' type=kotlin.Unit origin=null - receiver: GET_VAR ': .Test declared in .Test' type=.Test origin=null - value: GET_VAR '_context_receiver_0: .Context declared in .Test.' type=.Context origin=null - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]' - FUN name:foo visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.Int - $this: VALUE_PARAMETER name: type:.Test - BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun foo (): kotlin.Int declared in .Test' - CONST Int type=kotlin.Int value=2 - FUN name:bar visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.Unit - $this: VALUE_PARAMETER name: type:.Test - BLOCK_BODY - VAR name:x type:kotlin.Int [val] - CALL 'public final fun foo (): kotlin.Int declared in .Context' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Context visibility:private [final]' type=.Context origin=null - receiver: GET_VAR ': .Test declared in .Test.bar' type=.Test 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 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.fir.kt.txt deleted file mode 100644 index b7d74ae7434..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.fir.kt.txt +++ /dev/null @@ -1,31 +0,0 @@ -class Context { - constructor() /* primary */ { - super/*Any*/() - /* () */ - - } - - fun foo(): Int { - return 1 - } - -} - -class Test { - private /* final field */ val contextReceiverField0: Context - constructor(_context_receiver_0: Context) /* primary */ { - super/*Any*/() - .#contextReceiverField0 = _context_receiver_0 - /* () */ - - } - - fun foo(): Int { - return 2 - } - - fun bar() { - val x: Int = .#contextReceiverField0.foo() - } - -} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.ir.txt index 45e69e18032..7c2160bbf44 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.ir.txt @@ -26,13 +26,13 @@ FILE fqName: fileName:/contextReceiverMethod.kt CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Context visibility:private [final] - CONSTRUCTOR visibility:public <> (:.Context) returnType:.Test [primary] - VALUE_PARAMETER name: index:0 type:.Context + CONSTRUCTOR visibility:public <> (_context_receiver_0:.Context) returnType:.Test [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:.Context BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Context visibility:private [final]' type=kotlin.Unit origin=null receiver: GET_VAR ': .Test declared in .Test' type=.Test origin=null - value: GET_VAR ': .Context declared in .Test.' type=.Context origin=null + value: GET_VAR '_context_receiver_0: .Context declared in .Test.' type=.Context origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[kotlin.Any]' FUN name:foo visibility:public modality:FINAL <> ($this:.Test) returnType:kotlin.Int $this: VALUE_PARAMETER name: type:.Test diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt index 25bb518232d..196e2a447f4 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ContextReceivers class Context { diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt.txt index 96b3893d8f6..b7d74ae7434 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextReceiverMethod.kt.txt @@ -13,9 +13,9 @@ class Context { class Test { private /* final field */ val contextReceiverField0: Context - constructor(: Context) /* primary */ { + constructor(_context_receiver_0: Context) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt deleted file mode 100644 index 29077396e4f..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.ir.txt +++ /dev/null @@ -1,103 +0,0 @@ -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' - 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 - 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 (_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 deleted file mode 100644 index fe771d02ea0..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.fir.kt.txt +++ /dev/null @@ -1,39 +0,0 @@ -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.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.ir.txt index 7b2a9c30d33..29077396e4f 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.ir.txt @@ -33,14 +33,14 @@ FILE fqName: fileName:/contextualPrimaryConstructorWithParams.kt 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 + 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' 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 + value: GET_VAR '_context_receiver_0: .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] @@ -95,8 +95,8 @@ FILE fqName: fileName:/contextualPrimaryConstructorWithParams.kt $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 + 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 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt index 69b158479ed..2bd75795632 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ContextReceivers class O(val o: String) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt.txt index c52fa7a0802..fe771d02ea0 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/contextualPrimaryConstructorWithParams.kt.txt @@ -13,9 +13,9 @@ class O { class OK { private /* final field */ val contextReceiverField0: O - constructor(: O, k: String) /* primary */ { + constructor(_context_receiver_0: O, k: String) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } @@ -32,7 +32,7 @@ class OK { fun box(): String { return with(receiver = O(o = "O"), block = local fun O.(): String { - val ok: OK = OK( = $this$with, k = "K") + val ok: OK = OK(_context_receiver_0 = $this$with, k = "K") return ok.() } ) diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.ir.txt index 99ebce6f577..c75eb707e04 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.ir.txt @@ -86,13 +86,13 @@ FILE fqName: fileName:/delegatedPropertiesOperators.kt 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 <> (:kotlin.Int) returnType:.Result [primary] - VALUE_PARAMETER name: index:0 type:kotlin.Int + 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' 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 ': kotlin.Int declared in .Result.' type=kotlin.Int origin=null + value: GET_VAR '_context_receiver_0: kotlin.Int declared in .Result.' type=kotlin.Int origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Result modality:FINAL visibility:public superTypes:[kotlin.Any]' PROPERTY name:s visibility:public modality:FINAL [delegated,var] FIELD PROPERTY_DELEGATE name:s$delegate type:.Delegate visibility:private [final] @@ -149,8 +149,8 @@ FILE fqName: fileName:/delegatedPropertiesOperators.kt $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 (: kotlin.Int) [primary] declared in .Result' type=.Result origin=null - : GET_VAR '$this$with: kotlin.Int declared in .box.' type=kotlin.Int origin=null + 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" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt.txt index 75ae8df8c4b..729a50c0552 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/delegatedPropertiesOperators.kt.txt @@ -33,9 +33,9 @@ class Delegate { class Result { private /* final field */ val contextReceiverField0: Int - constructor(: Int) /* primary */ { + constructor(_context_receiver_0: Int) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } @@ -53,7 +53,7 @@ class Result { fun box(): String { val result: Result = with(receiver = 1, block = local fun Int.(): Result { - return Result( = $this$with) + return Result(_context_receiver_0 = $this$with) } ) result.( = "OK") diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt deleted file mode 100644 index d219678c4ab..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt +++ /dev/null @@ -1,65 +0,0 @@ -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 - 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' - 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 - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A 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: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 - 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' - 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 - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B 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:foo visibility:public modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Unit - $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 (_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 (_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 deleted file mode 100644 index b248966aae9..00000000000 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt +++ /dev/null @@ -1,29 +0,0 @@ -class A { - private /* final field */ val contextReceiverField0: T - constructor(_context_receiver_0: T) /* primary */ { - super/*Any*/() - .#contextReceiverField0 = _context_receiver_0 - /* () */ - - } - -} - -class B

{ - private /* final field */ val contextReceiverField0: Collection

- constructor(_context_receiver_0: Collection

) /* primary */ { - super/*Any*/() - .#contextReceiverField0 = _context_receiver_0 - /* () */ - - } - -} - -fun Int.foo() { - A(_context_receiver_0 = ) /*~> Unit */ -} - -fun Collection.bar() { - B(_context_receiver_0 = ) /*~> Unit */ -} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt index 90903c27583..d219678c4ab 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt @@ -3,13 +3,13 @@ FILE fqName: fileName:/genericOuterClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.A> TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:T of .A visibility:private [final] - CONSTRUCTOR visibility:public <> (:T of .A) returnType:.A.A> [primary] - VALUE_PARAMETER name: index:0 type:T of .A + 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' 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 ': T of .A declared in .A.' type=T of .A origin=null + value: GET_VAR '_context_receiver_0: T of .A declared in .A.' type=T of .A origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A 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: @@ -28,13 +28,13 @@ FILE fqName: fileName:/genericOuterClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B

.B> TYPE_PARAMETER name:P index:0 variance: superTypes:[kotlin.Any?] reified:false FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.collections.Collection

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

.B>) returnType:.B

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

.B> + 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' 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 ': kotlin.collections.Collection

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

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

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

.B> origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B 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: @@ -53,13 +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 (: T of .A) [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 - : GET_VAR ': kotlin.Int declared in .foo' type=kotlin.Int origin=null + _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 (: kotlin.collections.Collection

.B>) [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 - : GET_VAR ': kotlin.collections.Collection declared in .bar' type=kotlin.collections.Collection origin=null + _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.kt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt index 0507c9ffb8d..85408477142 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !LANGUAGE: +ContextReceivers context(T) class A diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt index 7e807299313..b248966aae9 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt @@ -1,8 +1,8 @@ class A { private /* final field */ val contextReceiverField0: T - constructor(: T) /* primary */ { + constructor(_context_receiver_0: T) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } @@ -11,9 +11,9 @@ class A { class B

{ private /* final field */ val contextReceiverField0: Collection

- constructor(: Collection

) /* primary */ { + constructor(_context_receiver_0: Collection

) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } @@ -21,9 +21,9 @@ class B

{ } 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.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.ir.txt index fde292de35a..52d31d5577b 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.ir.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.ir.txt @@ -192,14 +192,14 @@ FILE fqName: fileName:/iteratorOperator.kt 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 <> (:.CounterConfig, counter:.Counter) returnType:.CounterIterator [primary] - VALUE_PARAMETER name: index:0 type:.CounterConfig + 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' 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 ': .CounterConfig declared in .CounterIterator.' type=.CounterConfig origin=null + value: GET_VAR '_context_receiver_0: .CounterConfig declared in .CounterIterator.' type=.CounterConfig origin=null INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:CounterIterator modality:FINAL visibility:public superTypes:[kotlin.collections.Iterator]' PROPERTY name:counter visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:counter type:.Counter visibility:private [final] @@ -272,8 +272,8 @@ FILE fqName: fileName:/iteratorOperator.kt $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 (: .CounterConfig, counter: .Counter) [primary] declared in .CounterIterator' type=.CounterIterator origin=null - : GET_VAR '$this$with: .CounterConfig declared in .iterator.' type=.CounterConfig origin=null + CONSTRUCTOR_CALL 'public constructor (_context_receiver_0: .CounterConfig, counter: .Counter) [primary] declared in .CounterIterator' type=.CounterIterator origin=null + _context_receiver_0: GET_VAR '$this$with: .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 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt.txt index b501af60d3f..0ea12516704 100644 --- a/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt.txt +++ b/compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt.txt @@ -87,9 +87,9 @@ data class CounterConfig { class CounterIterator : Iterator { private /* final field */ val contextReceiverField0: CounterConfig - constructor(: CounterConfig, counter: Counter) /* primary */ { + constructor(_context_receiver_0: CounterConfig, counter: Counter) /* primary */ { super/*Any*/() - .#contextReceiverField0 = + .#contextReceiverField0 = _context_receiver_0 /* () */ } @@ -117,7 +117,7 @@ class CounterIterator : Iterator { operator fun Counter.iterator(_context_receiver_0: CounterConfig): CounterIterator { return with(receiver = _context_receiver_0, block = local fun CounterConfig.(): CounterIterator { - return CounterIterator( = $this$with, counter = ) + return CounterIterator(_context_receiver_0 = $this$with, counter = ) } ) } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.ir.txt new file mode 100644 index 00000000000..905edbb58e2 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.ir.txt @@ -0,0 +1,30 @@ +FILE fqName: fileName:/kt52791.kt + CLASS CLASS name:MyClass modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyClass + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.Unit visibility:private [final] + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField1 type:kotlin.Int visibility:private [final] + CONSTRUCTOR visibility:public <> (_context_receiver_0:kotlin.Unit, _context_receiver_1:kotlin.Int) returnType:.MyClass [primary] + VALUE_PARAMETER name:_context_receiver_0 index:0 type:kotlin.Unit + VALUE_PARAMETER name:_context_receiver_1 index:1 type:kotlin.Int + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:kotlin.Unit visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .MyClass declared in .MyClass' type=.MyClass origin=null + value: GET_VAR '_context_receiver_0: kotlin.Unit declared in .MyClass.' type=kotlin.Unit origin=null + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField1 type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .MyClass declared in .MyClass' type=.MyClass origin=null + value: GET_VAR '_context_receiver_1: kotlin.Int declared in .MyClass.' type=kotlin.Int origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyClass 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 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt b/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt new file mode 100644 index 00000000000..72bfbffee29 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt @@ -0,0 +1,6 @@ +// !LANGUAGE: +ContextReceivers +// FIR_IDENTICAL +// TARGET_BACKEND: JVM_IR + +context(Unit, Int) +class MyClass \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt.txt new file mode 100644 index 00000000000..f46f04f54d3 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt.txt @@ -0,0 +1,12 @@ +class MyClass { + private /* final field */ val contextReceiverField0: Unit + private /* final field */ val contextReceiverField1: Int + constructor(_context_receiver_0: Unit, _context_receiver_1: Int) /* primary */ { + super/*Any*/() + .#contextReceiverField0 = _context_receiver_0 + .#contextReceiverField1 = _context_receiver_1 + /* () */ + + } + +} 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 e429796d170..45b047ef927 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 @@ -17215,6 +17215,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/extensionClasses/generics.kt"); } + @Test + @TestMetadata("multiple.kt") + public void testMultiple() throws Exception { + runTest("compiler/testData/codegen/box/extensionClasses/multiple.kt"); + } + @Test @TestMetadata("propertyWithContext.kt") public void testPropertyWithContext() 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 78d43597787..de94b5a5f0d 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 @@ -859,6 +859,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/declarations/contextReceivers/iteratorOperator.kt"); } + @Test + @TestMetadata("kt52791.kt") + public void testKt52791() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/kt52791.kt"); + } + @Test @TestMetadata("lazy.kt") public void testLazy() throws Exception { diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt index 24cc18c5a6e..48d309f2f18 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/TypeAliasConstructorDescriptor.kt @@ -206,12 +206,13 @@ class TypeAliasConstructorDescriptorImpl private constructor( val classDescriptor = typeAliasDescriptor.classDescriptor val contextReceiverParameters = classDescriptor?.let { - constructor.contextReceiverParameters.map { + constructor.contextReceiverParameters.mapIndexed { index, contextReceiver -> DescriptorFactory.createContextReceiverParameterForClass( classDescriptor, - substitutorForUnderlyingClass.safeSubstitute(it.type, Variance.INVARIANT), - (it.value as ImplicitContextReceiver).customLabelName, - Annotations.EMPTY + substitutorForUnderlyingClass.safeSubstitute(contextReceiver.type, Variance.INVARIANT), + (contextReceiver.value as ImplicitContextReceiver).customLabelName, + Annotations.EMPTY, + index ) } } ?: emptyList() diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java index 9432ed863e8..8dda387da33 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorFactory.java @@ -246,10 +246,12 @@ public class DescriptorFactory { @NotNull ClassDescriptor owner, @Nullable KotlinType receiverParameterType, @Nullable Name customLabelName, - @NotNull Annotations annotations + @NotNull Annotations annotations, + int index ) { return receiverParameterType == null ? null - : new ReceiverParameterDescriptorImpl(owner, new ContextClassReceiver(owner, receiverParameterType, customLabelName, null), annotations); + : new ReceiverParameterDescriptorImpl(owner, new ContextClassReceiver(owner, receiverParameterType, customLabelName, null), + annotations, NameUtils.contextReceiverName(index)); } }