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 64269518bf8..2919441a995 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 @@ -742,6 +742,122 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers") + @TestDataPath("$PROJECT_ROOT") + public class ContextReceivers { + @Test + public void testAllFilesPresentInContextReceivers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("class.kt") + public void testClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/class.kt"); + } + + @Test + @TestMetadata("function.kt") + public void testFunction() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/function.kt"); + } + + @Test + @TestMetadata("functionalType.kt") + public void testFunctionalType() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt"); + } + + @Test + @TestMetadata("genericOuterClass.kt") + public void testGenericOuterClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt"); + } + + @Test + @TestMetadata("lazy.kt") + public void testLazy() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt"); + } + + @Test + @TestMetadata("localDeclaration.kt") + public void testLocalDeclaration() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt"); + } + + @Test + @TestMetadata("overloadPriority.kt") + public void testOverloadPriority() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt"); + } + + @Test + @TestMetadata("overloading.kt") + public void testOverloading() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt"); + } + + @Test + @TestMetadata("plusMatrix.kt") + public void testPlusMatrix() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt"); + } + + @Test + @TestMetadata("property.kt") + public void testProperty() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/property.kt"); + } + + @Test + @TestMetadata("thisWithCustomLabel.kt") + public void testThisWithCustomLabel() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt"); + } + + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + public class FromKEEP { + @Test + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt"); + } + + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt"); + } + + @Test + @TestMetadata("functionalType.kt") + public void testFunctionalType() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/multiplatform") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.ir.txt new file mode 100644 index 00000000000..ad2ea8af626 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.ir.txt @@ -0,0 +1,79 @@ +FILE fqName: fileName:/class.kt + CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer + CONSTRUCTOR visibility:public <> () returnType:.Outer [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Outer) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Outer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Outer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Outer declared in .Outer.' type=.Outer origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Inner modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inner + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.Outer visibility:private [final] + CONSTRUCTOR visibility:public <> (:.Outer, arg:kotlin.Any) returnType:.Inner [primary] + VALUE_PARAMETER name: 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 + 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 (: .Outer, arg: kotlin.Any) [primary] declared in .Inner' type=.Inner origin=null + : 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 new file mode 100644 index 00000000000..cfa072d71de --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +class Outer { + val x: Int = 1 +} + +context(Outer) +class Inner(arg: Any) { + fun bar() = x +} + +fun f(outer: Outer) { + with(outer) { + Inner(3) + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt new file mode 100644 index 00000000000..25fc4cc7bdf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.kt.txt @@ -0,0 +1,34 @@ +class Outer { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val x: Int + field = 1 + get + +} + +class Inner { + private /* final field */ val additionalReceiverField0: Outer + constructor(: Outer, arg: Any) /* primary */ { + super/*Any*/() + .#additionalReceiverField0 = + /* () */ + + } + + fun bar(): Int { + return .#additionalReceiverField0.() + } + +} + +fun f(outer: Outer) { + with(receiver = outer, block = local fun Outer.(): Inner { + return Inner( = $this$with, arg = 3) + } +) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/class.txt b/compiler/testData/ir/irText/declarations/contextReceivers/class.txt new file mode 100644 index 00000000000..d85161c1c26 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/class.txt @@ -0,0 +1,79 @@ +FILE fqName: fileName:/class.kt + CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Outer + CONSTRUCTOR visibility:public <> () returnType:.Outer [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:x visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=1 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Outer) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.Outer + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .Outer' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .Outer declared in .Outer.' type=.Outer origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Inner modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Inner + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:additionalReceiverField0 type:.Outer visibility:private [final] + CONSTRUCTOR visibility:public <> (:.Outer, arg:kotlin.Any) returnType:.Inner [primary] + VALUE_PARAMETER name: 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:additionalReceiverField0 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 + 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:additionalReceiverField0 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 (: .Outer, arg: kotlin.Any) [primary] declared in .Inner' type=.Inner origin=null + : 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/fromKEEP/canvas.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.ir.txt new file mode 100644 index 00000000000..626d2a2c5ad --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.ir.txt @@ -0,0 +1,117 @@ +FILE fqName: fileName:/canvas.kt + CLASS INTERFACE name:Canvas modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Canvas + PROPERTY name:suffix visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Canvas) returnType:kotlin.String + correspondingProperty: PROPERTY name:suffix visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.Canvas + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Shape modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Shape + FUN name:draw visibility:public modality:ABSTRACT <> ($this:.Shape, :.Canvas) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Shape + VALUE_PARAMETER name: index:0 type:.Canvas + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[.Shape] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Circle + CONSTRUCTOR visibility:public <> () returnType:.Circle [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[.Shape]' + FUN name:draw visibility:public modality:OPEN <> ($this:.Circle, :.Canvas) returnType:kotlin.String + overridden: + public abstract fun draw (: .Canvas): kotlin.String declared in .Shape + $this: VALUE_PARAMETER name: type:.Circle + VALUE_PARAMETER name: index:0 type:.Canvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun draw (: .Canvas): kotlin.String declared in .Circle' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="OK" + other: CALL 'public abstract fun (): kotlin.String declared in .Canvas' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .Canvas declared in .Circle.draw' type=.Canvas origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyCanvas + CONSTRUCTOR visibility:private <> () returnType:.MyCanvas [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas]' + PROPERTY name:suffix visibility:public modality:OPEN [val] + overridden: + public abstract suffix: kotlin.String [val] + FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:OPEN <> ($this:.MyCanvas) returnType:kotlin.String + correspondingProperty: PROPERTY name:suffix visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.String declared in .Canvas + $this: VALUE_PARAMETER name: type:.MyCanvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .MyCanvas' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .MyCanvas declared in .MyCanvas.' type=.MyCanvas origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .MyCanvas + : kotlin.String + receiver: GET_OBJECT 'CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas]' type=.MyCanvas + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.MyCanvas, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.MyCanvas) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.MyCanvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public open fun draw (: .Canvas): kotlin.String declared in .Circle' type=kotlin.String origin=null + $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Circle' type=.Circle origin=null + : GET_VAR '$this$with: .MyCanvas declared in .box.' type=.MyCanvas origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt new file mode 100644 index 00000000000..95f59cbcffa --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR + +interface Canvas { + val suffix: String +} + +interface Shape { + context(Canvas) + fun draw(): String +} + +class Circle : Shape { + context(Canvas) + override fun draw() = "OK" + suffix +} + +object MyCanvas : Canvas { + override val suffix = "" +} + +fun box() = with(MyCanvas) { Circle().draw() } \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt.txt new file mode 100644 index 00000000000..facee9860e2 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt.txt @@ -0,0 +1,43 @@ +interface Canvas { + abstract val suffix: String + abstract get + +} + +interface Shape { + abstract fun draw(: Canvas): String + +} + +class Circle : Shape { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override fun draw(: Canvas): String { + return "OK".plus(other = .()) + } + +} + +object MyCanvas : Canvas { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override val suffix: String + field = "" + override get + +} + +fun box(): String { + return with(receiver = MyCanvas, block = local fun MyCanvas.(): String { + return Circle().draw( = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.txt new file mode 100644 index 00000000000..626d2a2c5ad --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.txt @@ -0,0 +1,117 @@ +FILE fqName: fileName:/canvas.kt + CLASS INTERFACE name:Canvas modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Canvas + PROPERTY name:suffix visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Canvas) returnType:kotlin.String + correspondingProperty: PROPERTY name:suffix visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.Canvas + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Shape modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Shape + FUN name:draw visibility:public modality:ABSTRACT <> ($this:.Shape, :.Canvas) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:.Shape + VALUE_PARAMETER name: index:0 type:.Canvas + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[.Shape] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Circle + CONSTRUCTOR visibility:public <> () returnType:.Circle [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Circle modality:FINAL visibility:public superTypes:[.Shape]' + FUN name:draw visibility:public modality:OPEN <> ($this:.Circle, :.Canvas) returnType:kotlin.String + overridden: + public abstract fun draw (: .Canvas): kotlin.String declared in .Shape + $this: VALUE_PARAMETER name: type:.Circle + VALUE_PARAMETER name: index:0 type:.Canvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun draw (: .Canvas): kotlin.String declared in .Circle' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CONST String type=kotlin.String value="OK" + other: CALL 'public abstract fun (): kotlin.String declared in .Canvas' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .Canvas declared in .Circle.draw' type=.Canvas origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Shape + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyCanvas + CONSTRUCTOR visibility:private <> () returnType:.MyCanvas [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas]' + PROPERTY name:suffix visibility:public modality:OPEN [val] + overridden: + public abstract suffix: kotlin.String [val] + FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:OPEN <> ($this:.MyCanvas) returnType:kotlin.String + correspondingProperty: PROPERTY name:suffix visibility:public modality:OPEN [val] + overridden: + public abstract fun (): kotlin.String declared in .Canvas + $this: VALUE_PARAMETER name: type:.MyCanvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .MyCanvas' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:suffix type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .MyCanvas declared in .MyCanvas.' type=.MyCanvas origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Canvas + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .MyCanvas + : kotlin.String + receiver: GET_OBJECT 'CLASS OBJECT name:MyCanvas modality:FINAL visibility:public superTypes:[.Canvas]' type=.MyCanvas + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.MyCanvas, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.MyCanvas) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.MyCanvas + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public open fun draw (: .Canvas): kotlin.String declared in .Circle' type=kotlin.String origin=null + $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Circle' type=.Circle origin=null + : GET_VAR '$this$with: .MyCanvas declared in .box.' type=.MyCanvas origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt new file mode 100644 index 00000000000..3d61c9a6bb9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.ir.txt @@ -0,0 +1,247 @@ +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/compareTo.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt new file mode 100644 index 00000000000..eb7443d7e12 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR + +data class Pair(val first: A, val second: B) + +context(Comparator) +infix operator fun T.compareTo(other: T) = compare(this, other) + +context(Comparator) +val Pair.min get() = if (first < second) first else second + +fun box(): String { + val comparator = Comparator { a, b -> + if (a == null || b == null) 0 else a.length.compareTo(b.length) + } + return with(comparator) { + Pair("OK", "fail").min + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt new file mode 100644 index 00000000000..245719306f7 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt.txt @@ -0,0 +1,90 @@ +data class Pair { + constructor(first: A, second: B) /* primary */ { + super/*Any*/() + /* () */ + + } + + val first: A + field = first + get + + val second: B + field = second + get + + operator fun component1(): A { + return .#first + } + + operator fun component2(): B { + return .#second + } + + fun copy(first: A = .#first, second: B = .#second): Pair { + return Pair(first = first, second = second) + } + + override fun toString(): String { + return "Pair(" + "first=" + .#first + ", " + "second=" + .#second + ")" + } + + override fun hashCode(): Int { + var result: Int = when { + EQEQ(arg0 = .#first, arg1 = null) -> 0 + else -> .#first.hashCode() + } + result = result.times(other = 31).plus(other = when { + EQEQ(arg0 = .#second, arg1 = null) -> 0 + else -> .#second.hashCode() + }) + return result + } + + override operator fun equals(other: Any?): Boolean { + when { + EQEQEQ(arg0 = , arg1 = other) -> return true + } + when { + other !is Pair -> return false + } + val tmp0_other_with_cast: Pair = other as Pair + when { + EQEQ(arg0 = .#first, arg1 = tmp0_other_with_cast.#first).not() -> return false + } + when { + EQEQ(arg0 = .#second, arg1 = tmp0_other_with_cast.#second).not() -> return false + } + return true + } + +} + +infix operator fun T.compareTo(: Comparator, other: T): Int { + return .compare(p0 = , p1 = other) +} + +val Pair.min: T + get(: Comparator): T { + return when { + less(arg0 = .().compareTo( = /*as T */, other = .()), arg1 = 0) -> .() + else -> .() + } + } + +fun box(): String { + val comparator: Comparator = local fun (a: @FlexibleNullability String?, b: @FlexibleNullability String?): Int { + return when { + when { + EQEQ(arg0 = a, arg1 = null) -> true + else -> EQEQ(arg0 = b, arg1 = null) + } -> 0 + else -> a /*!! String */.().compareTo(other = b /*!! String */.()) + } + } + /*-> Comparator */ + return with, String>(receiver = comparator, block = local fun Comparator.(): String { + return Pair(first = "OK", second = "fail").( = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.txt new file mode 100644 index 00000000000..3d61c9a6bb9 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.txt @@ -0,0 +1,247 @@ +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/dp.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.ir.txt new file mode 100644 index 00000000000..d892d912efc --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.ir.txt @@ -0,0 +1,83 @@ +FILE fqName: fileName:/dp.kt + CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.View + CONSTRUCTOR visibility:public <> () returnType:.View [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:coefficient visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.View) returnType:kotlin.Int + correspondingProperty: PROPERTY name:coefficient visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.View + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .View' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .View declared in .View.' type=.View origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:dp visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Int, :.View) returnType:kotlin.Int + correspondingProperty: PROPERTY name:dp visibility:public modality:FINAL [val] + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name: index:0 type:.View + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (: .View): kotlin.Int declared in ' + CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CALL 'public final fun (): kotlin.Int declared in .View' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .View declared in .' type=.View origin=null + other: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + : .View + : kotlin.Nothing + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .View' type=.View origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.View, kotlin.Nothing> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.View) returnType:kotlin.Nothing + $receiver: VALUE_PARAMETER name:$this$with type:.View + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + : kotlin.Int + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=10 + transform: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:it index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Int declared in .box.' + CALL 'public final fun (: .View): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'it: kotlin.Int declared in .box..' type=kotlin.Int origin=null + : GET_VAR '$this$with: .View declared in .box.' type=.View origin=null + arg1: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=42 + CONST Int type=kotlin.Int value=84 + CONST Int type=kotlin.Int value=420 + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt new file mode 100644 index 00000000000..9973c7a317a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt @@ -0,0 +1,19 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// WITH_RUNTIME + +class View { + val coefficient = 42 +} + +context(View) val Int.dp get() = coefficient * this + +fun box(): String { + with(View()) { + if (listOf(1, 2, 10).map { it.dp } == listOf(42, 84, 420)) { + return "OK" + } + return "fail" + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt.txt new file mode 100644 index 00000000000..8bf3626edcf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt.txt @@ -0,0 +1,32 @@ +class View { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val coefficient: Int + field = 42 + get + +} + +val Int.dp: Int + get(: View): Int { + return .().times(other = ) + } + +fun box(): String { + with(receiver = View(), block = local fun View.(): Nothing { + when { + EQEQ(arg0 = listOf(elements = [1, 2, 10]).map(transform = local fun (it: Int): Int { + return it.( = $this$with) + } +), arg1 = listOf(elements = [42, 84, 420])) -> { // BLOCK + return "OK" + } + } + return "fail" + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.txt new file mode 100644 index 00000000000..d892d912efc --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.txt @@ -0,0 +1,83 @@ +FILE fqName: fileName:/dp.kt + CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.View + CONSTRUCTOR visibility:public <> () returnType:.View [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:View modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:coefficient visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.View) returnType:kotlin.Int + correspondingProperty: PROPERTY name:coefficient visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.View + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .View' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:coefficient type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .View declared in .View.' type=.View origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:dp visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($receiver:kotlin.Int, :.View) returnType:kotlin.Int + correspondingProperty: PROPERTY name:dp visibility:public modality:FINAL [val] + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name: index:0 type:.View + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (: .View): kotlin.Int declared in ' + CALL 'public final fun times (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MUL + $this: CALL 'public final fun (): kotlin.Int declared in .View' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .View declared in .' type=.View origin=null + other: GET_VAR ': kotlin.Int declared in .' type=kotlin.Int origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + : .View + : kotlin.Nothing + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .View' type=.View origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.View, kotlin.Nothing> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.View) returnType:kotlin.Nothing + $receiver: VALUE_PARAMETER name:$this$with type:.View + BLOCK_BODY + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun map (transform: kotlin.Function1): kotlin.collections.List [inline] declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + : kotlin.Int + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=10 + transform: FUN_EXPR type=kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name:it index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (it: kotlin.Int): kotlin.Int declared in .box.' + CALL 'public final fun (: .View): kotlin.Int declared in ' type=kotlin.Int origin=GET_PROPERTY + $receiver: GET_VAR 'it: kotlin.Int declared in .box..' type=kotlin.Int origin=null + : GET_VAR '$this$with: .View declared in .box.' type=.View origin=null + arg1: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=42 + CONST Int type=kotlin.Int value=84 + CONST Int type=kotlin.Int value=420 + then: BLOCK type=kotlin.Unit origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="OK" + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CONST String type=kotlin.String value="fail" diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt new file mode 100644 index 00000000000..d7826db9cab --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.ir.txt @@ -0,0 +1,121 @@ +FILE fqName: fileName:/functionalType.kt + CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Param + CONSTRUCTOR visibility:public <> () returnType:.Param [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.O + CONSTRUCTOR visibility:public <> () returnType:.O [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:o visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="O" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.O) returnType:kotlin.String + correspondingProperty: PROPERTY name:o visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .O' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .O declared in .O.' type=.O origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K + CONSTRUCTOR visibility:public <> () returnType:.K [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:k visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="K" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.K) returnType:kotlin.String + correspondingProperty: PROPERTY name:k visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.K + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .K' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .K declared in .K.' type=.K origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL ($receiver:.K, :.O, g:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f>) returnType:T of .f + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.K + VALUE_PARAMETER name: index:0 type:.O + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (: .O, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f>): T of .f declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function3, p2: P2 of kotlin.Function3, p3: P3 of kotlin.Function3): R of kotlin.Function3 [operator] declared in kotlin.Function3' type=T of .f origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f> declared in .f' type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .O declared in .f' type=.O origin=null + p2: GET_VAR ': .K declared in .f' type=.K origin=null + p3: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .O + : kotlin.String + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .O' type=.O origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.O, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.O) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun f (: .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 + 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 + VALUE_PARAMETER name: index:0 type:.O + VALUE_PARAMETER name:it index:1 type:.Param + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (: .O, it: .Param): kotlin.String declared in .box.' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun (): kotlin.String declared in .O' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this$with: .O declared in .box.' type=.O origin=null + other: CALL 'public final fun (): kotlin.String declared in .K' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this$f: .K declared in .box..' type=.K origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt new file mode 100644 index 00000000000..b869312df46 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR + +class Param +class O { + val o = "O" +} +class K { + val k = "K" +} + +context(O) +fun K.f(g: context(O) K.(Param) -> T) = g(this@O, this@K, Param()) + +fun box() = with(O()) { + K().f { o + k } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt new file mode 100644 index 00000000000..d45d2e63895 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt.txt @@ -0,0 +1,48 @@ +class Param { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class O { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val o: String + field = "O" + get + +} + +class K { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val k: String + field = "K" + get + +} + +fun K.f(: O, g: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3): T { + return g.invoke(p1 = , p2 = , p3 = Param()) +} + +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 $this$with.().plus(other = $this$f.()) + } +) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.txt new file mode 100644 index 00000000000..d7826db9cab --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.txt @@ -0,0 +1,121 @@ +FILE fqName: fileName:/functionalType.kt + CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Param + CONSTRUCTOR visibility:public <> () returnType:.Param [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.O + CONSTRUCTOR visibility:public <> () returnType:.O [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:O modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:o visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="O" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.O) returnType:kotlin.String + correspondingProperty: PROPERTY name:o visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .O' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:o type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .O declared in .O.' type=.O origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K + CONSTRUCTOR visibility:public <> () returnType:.K [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:K modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:k visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="K" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.K) returnType:kotlin.String + correspondingProperty: PROPERTY name:k visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.K + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in .K' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:k type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .K declared in .K.' type=.K origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL ($receiver:.K, :.O, g:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f>) returnType:T of .f + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.K + VALUE_PARAMETER name: index:0 type:.O + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (: .O, g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f>): T of .f declared in ' + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function3, p2: P2 of kotlin.Function3, p3: P3 of kotlin.Function3): R of kotlin.Function3 [operator] declared in kotlin.Function3' type=T of .f origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f> declared in .f' type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.O, .K, .Param, T of .f> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .O declared in .f' type=.O origin=null + p2: GET_VAR ': .K declared in .f' type=.K origin=null + p3: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .O + : kotlin.String + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .O' type=.O origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.O, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.O) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.O + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun f (: .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 + 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 + VALUE_PARAMETER name: index:0 type:.O + VALUE_PARAMETER name:it index:1 type:.Param + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (: .O, it: .Param): kotlin.String declared in .box.' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: CALL 'public final fun (): kotlin.String declared in .O' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this$with: .O declared in .box.' type=.O origin=null + other: CALL 'public final fun (): kotlin.String declared in .K' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR '$this$f: .K declared in .box..' type=.K origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.ir.txt new file mode 100644 index 00000000000..50d56a6e1e4 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.ir.txt @@ -0,0 +1,198 @@ +FILE fqName: fileName:/monoidSum.kt + CLASS INTERFACE name:Semigroup modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Semigroup.Semigroup> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + FUN name:combine visibility:public modality:ABSTRACT <> ($this:.Semigroup.Semigroup>, $receiver:T of .Semigroup, other:T of .Semigroup) returnType:T of .Semigroup [infix] + $this: VALUE_PARAMETER name: type:.Semigroup.Semigroup> + $receiver: VALUE_PARAMETER name: type:T of .Semigroup + VALUE_PARAMETER name:other index:0 type:T of .Semigroup + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Monoid modality:ABSTRACT visibility:public superTypes:[.Semigroup.Monoid>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Monoid.Monoid> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + PROPERTY name:unit visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Monoid.Monoid>) returnType:T of .Monoid + correspondingProperty: PROPERTY name:unit visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.Monoid.Monoid> + FUN FAKE_OVERRIDE name:combine visibility:public modality:ABSTRACT <> ($this:.Semigroup.Monoid>, $receiver:T of .Monoid, other:T of .Monoid) returnType:T of .Monoid [fake_override,infix] + overridden: + public abstract fun combine (other: T of .Semigroup): T of .Semigroup [infix] declared in .Semigroup + $this: VALUE_PARAMETER name: type:.Semigroup.Monoid> + $receiver: VALUE_PARAMETER name: type:T of .Monoid + VALUE_PARAMETER name:other index:0 type:T of .Monoid + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IntMonoid + CONSTRUCTOR visibility:private <> () returnType:.IntMonoid [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid]' + FUN name:combine visibility:public modality:OPEN <> ($this:.IntMonoid, $receiver:kotlin.Int, other:kotlin.Int) returnType:kotlin.Int [infix] + overridden: + public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid + $this: VALUE_PARAMETER name: type:.IntMonoid + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:other index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun combine (other: kotlin.Int): kotlin.Int [infix] declared in .IntMonoid' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .IntMonoid.combine' type=kotlin.Int origin=null + other: GET_VAR 'other: kotlin.Int declared in .IntMonoid.combine' type=kotlin.Int origin=null + PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract unit: T of .Monoid [val] + FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:OPEN <> ($this:.IntMonoid) returnType:kotlin.Int + correspondingProperty: PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract fun (): T of .Monoid declared in .Monoid + $this: VALUE_PARAMETER name: type:.IntMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .IntMonoid' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IntMonoid declared in .IntMonoid.' type=.IntMonoid origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.StringMonoid + CONSTRUCTOR visibility:private <> () returnType:.StringMonoid [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid]' + FUN name:combine visibility:public modality:OPEN <> ($this:.StringMonoid, $receiver:kotlin.String, other:kotlin.String) returnType:kotlin.String [infix] + overridden: + public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid + $this: VALUE_PARAMETER name: type:.StringMonoid + $receiver: VALUE_PARAMETER name: type:kotlin.String + VALUE_PARAMETER name:other index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun combine (other: kotlin.String): kotlin.String [infix] declared in .StringMonoid' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: GET_VAR ': kotlin.String declared in .StringMonoid.combine' type=kotlin.String origin=null + other: GET_VAR 'other: kotlin.String declared in .StringMonoid.combine' type=kotlin.String origin=null + PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract unit: T of .Monoid [val] + FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:OPEN <> ($this:.StringMonoid) returnType:kotlin.String + correspondingProperty: PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract fun (): T of .Monoid declared in .Monoid + $this: VALUE_PARAMETER name: type:.StringMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .StringMonoid' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .StringMonoid declared in .StringMonoid.' type=.StringMonoid origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:sum visibility:public modality:FINAL ($receiver:kotlin.collections.List.sum>, :.Monoid.sum>) returnType:T of .sum + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.sum> + VALUE_PARAMETER name: index:0 type:.Monoid.sum> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun sum (: .Monoid.sum>): T of .sum declared in ' + CALL 'public final fun fold (initial: R of kotlin.collections.CollectionsKt.fold, operation: kotlin.Function2<@[ParameterName(name = 'acc')] R of kotlin.collections.CollectionsKt.fold, T of kotlin.collections.CollectionsKt.fold, R of kotlin.collections.CollectionsKt.fold>): R of kotlin.collections.CollectionsKt.fold [inline] declared in kotlin.collections.CollectionsKt' type=T of .sum origin=null + : T of .sum + : T of .sum + $receiver: GET_VAR ': kotlin.collections.List.sum> declared in .sum' type=kotlin.collections.List.sum> origin=null + initial: CALL 'public abstract fun (): T of .Monoid declared in .Monoid' type=T of .sum origin=GET_PROPERTY + $this: GET_VAR ': .Monoid.sum> declared in .sum' type=.Monoid.sum> origin=null + operation: FUN_EXPR type=kotlin.Function2<@[ParameterName(name = 'acc')] T of .sum, T of .sum, T of .sum> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (acc:T of .sum, e:T of .sum) returnType:T of .sum + VALUE_PARAMETER name:acc index:0 type:T of .sum + VALUE_PARAMETER name:e index:1 type:T of .sum + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (acc: T of .sum, e: T of .sum): T of .sum declared in .sum' + CALL 'public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid' type=T of .sum origin=null + $this: GET_VAR ': .Monoid.sum> declared in .sum' type=.Monoid.sum> origin=null + $receiver: GET_VAR 'acc: T of .sum declared in .sum.' type=T of .sum origin=null + other: GET_VAR 'e: T of .sum declared in .sum.' type=T of .sum origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : .IntMonoid + : kotlin.Int + receiver: GET_OBJECT 'CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid]' type=.IntMonoid + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.IntMonoid, kotlin.Int> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.IntMonoid) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:.IntMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .box' + CALL 'public final fun sum (: .Monoid.sum>): T of .sum declared in ' type=kotlin.Int origin=null + : kotlin.Int + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=3 + : GET_VAR '$this$with: .IntMonoid declared in .box.' type=.IntMonoid origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .StringMonoid + : kotlin.String + receiver: GET_OBJECT 'CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid]' type=.StringMonoid + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.StringMonoid, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.StringMonoid) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.StringMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun sum (: .Monoid.sum>): T of .sum declared in ' type=kotlin.String origin=null + : kotlin.String + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.String + elements: VARARG type=kotlin.Array varargElementType=kotlin.String + CONST String type=kotlin.String value="O" + CONST String type=kotlin.String value="K" + : GET_VAR '$this$with: .StringMonoid declared in .box.' type=.StringMonoid origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt new file mode 100644 index 00000000000..6c3c3d3cd00 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt @@ -0,0 +1,32 @@ +// !LANGUAGE: +ContextReceivers +// TARGET_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// WITH_RUNTIME + +interface Semigroup { + infix fun T.combine(other: T): T +} + +interface Monoid : Semigroup { + val unit: T +} +object IntMonoid : Monoid { + override fun Int.combine(other: Int): Int = this + other + override val unit: Int = 0 +} +object StringMonoid : Monoid { + override fun String.combine(other: String): String = this + other + override val unit: String = "" +} + +context(Monoid) +fun List.sum(): T = fold(unit) { acc, e -> acc.combine(e) } + +fun box(): String { + with(IntMonoid) { + listOf(1, 2, 3).sum() + } + return with(StringMonoid) { + listOf("O", "K").sum() + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt.txt new file mode 100644 index 00000000000..542b8284b8c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt.txt @@ -0,0 +1,62 @@ +interface Semigroup { + abstract infix fun T.combine(other: T): T + +} + +interface Monoid : Semigroup { + abstract val unit: T + abstract get + +} + +object IntMonoid : Monoid { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override infix fun Int.combine(other: Int): Int { + return .plus(other = other) + } + + override val unit: Int + field = 0 + override get + +} + +object StringMonoid : Monoid { + private constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + override infix fun String.combine(other: String): String { + return .plus(other = other) + } + + override val unit: String + field = "" + override get + +} + +fun List.sum(: Monoid): T { + return .fold(initial = .(), operation = local fun (acc: T, e: T): T { + return (, acc).combine(other = e) + } +) +} + +fun box(): String { + with(receiver = IntMonoid, block = local fun IntMonoid.(): Int { + return listOf(elements = [1, 2, 3]).sum( = $this$with) + } +) /*~> Unit */ + return with(receiver = StringMonoid, block = local fun StringMonoid.(): String { + return listOf(elements = ["O", "K"]).sum( = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.txt b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.txt new file mode 100644 index 00000000000..50d56a6e1e4 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.txt @@ -0,0 +1,198 @@ +FILE fqName: fileName:/monoidSum.kt + CLASS INTERFACE name:Semigroup modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Semigroup.Semigroup> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + FUN name:combine visibility:public modality:ABSTRACT <> ($this:.Semigroup.Semigroup>, $receiver:T of .Semigroup, other:T of .Semigroup) returnType:T of .Semigroup [infix] + $this: VALUE_PARAMETER name: type:.Semigroup.Semigroup> + $receiver: VALUE_PARAMETER name: type:T of .Semigroup + VALUE_PARAMETER name:other index:0 type:T of .Semigroup + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Monoid modality:ABSTRACT visibility:public superTypes:[.Semigroup.Monoid>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Monoid.Monoid> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + PROPERTY name:unit visibility:public modality:ABSTRACT [val] + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:ABSTRACT <> ($this:.Monoid.Monoid>) returnType:T of .Monoid + correspondingProperty: PROPERTY name:unit visibility:public modality:ABSTRACT [val] + $this: VALUE_PARAMETER name: type:.Monoid.Monoid> + FUN FAKE_OVERRIDE name:combine visibility:public modality:ABSTRACT <> ($this:.Semigroup.Monoid>, $receiver:T of .Monoid, other:T of .Monoid) returnType:T of .Monoid [fake_override,infix] + overridden: + public abstract fun combine (other: T of .Semigroup): T of .Semigroup [infix] declared in .Semigroup + $this: VALUE_PARAMETER name: type:.Semigroup.Monoid> + $receiver: VALUE_PARAMETER name: type:T of .Monoid + VALUE_PARAMETER name:other index:0 type:T of .Monoid + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Semigroup + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.IntMonoid + CONSTRUCTOR visibility:private <> () returnType:.IntMonoid [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid]' + FUN name:combine visibility:public modality:OPEN <> ($this:.IntMonoid, $receiver:kotlin.Int, other:kotlin.Int) returnType:kotlin.Int [infix] + overridden: + public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid + $this: VALUE_PARAMETER name: type:.IntMonoid + $receiver: VALUE_PARAMETER name: type:kotlin.Int + VALUE_PARAMETER name:other index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun combine (other: kotlin.Int): kotlin.Int [infix] declared in .IntMonoid' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .IntMonoid.combine' type=kotlin.Int origin=null + other: GET_VAR 'other: kotlin.Int declared in .IntMonoid.combine' type=kotlin.Int origin=null + PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract unit: T of .Monoid [val] + FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=0 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:OPEN <> ($this:.IntMonoid) returnType:kotlin.Int + correspondingProperty: PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract fun (): T of .Monoid declared in .Monoid + $this: VALUE_PARAMETER name: type:.IntMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .IntMonoid' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .IntMonoid declared in .IntMonoid.' type=.IntMonoid origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.StringMonoid + CONSTRUCTOR visibility:private <> () returnType:.StringMonoid [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid]' + FUN name:combine visibility:public modality:OPEN <> ($this:.StringMonoid, $receiver:kotlin.String, other:kotlin.String) returnType:kotlin.String [infix] + overridden: + public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid + $this: VALUE_PARAMETER name: type:.StringMonoid + $receiver: VALUE_PARAMETER name: type:kotlin.String + VALUE_PARAMETER name:other index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun combine (other: kotlin.String): kotlin.String [infix] declared in .StringMonoid' + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS + $this: GET_VAR ': kotlin.String declared in .StringMonoid.combine' type=kotlin.String origin=null + other: GET_VAR 'other: kotlin.String declared in .StringMonoid.combine' type=kotlin.String origin=null + PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract unit: T of .Monoid [val] + FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:OPEN <> ($this:.StringMonoid) returnType:kotlin.String + correspondingProperty: PROPERTY name:unit visibility:public modality:OPEN [val] + overridden: + public abstract fun (): T of .Monoid declared in .Monoid + $this: VALUE_PARAMETER name: type:.StringMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .StringMonoid' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:unit type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': .StringMonoid declared in .StringMonoid.' type=.StringMonoid origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .Monoid + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:sum visibility:public modality:FINAL ($receiver:kotlin.collections.List.sum>, :.Monoid.sum>) returnType:T of .sum + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:kotlin.collections.List.sum> + VALUE_PARAMETER name: index:0 type:.Monoid.sum> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun sum (: .Monoid.sum>): T of .sum declared in ' + CALL 'public final fun fold (initial: R of kotlin.collections.CollectionsKt.fold, operation: kotlin.Function2<@[ParameterName(name = 'acc')] R of kotlin.collections.CollectionsKt.fold, T of kotlin.collections.CollectionsKt.fold, R of kotlin.collections.CollectionsKt.fold>): R of kotlin.collections.CollectionsKt.fold [inline] declared in kotlin.collections.CollectionsKt' type=T of .sum origin=null + : T of .sum + : T of .sum + $receiver: GET_VAR ': kotlin.collections.List.sum> declared in .sum' type=kotlin.collections.List.sum> origin=null + initial: CALL 'public abstract fun (): T of .Monoid declared in .Monoid' type=T of .sum origin=GET_PROPERTY + $this: GET_VAR ': .Monoid.sum> declared in .sum' type=.Monoid.sum> origin=null + operation: FUN_EXPR type=kotlin.Function2<@[ParameterName(name = 'acc')] T of .sum, T of .sum, T of .sum> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (acc:T of .sum, e:T of .sum) returnType:T of .sum + VALUE_PARAMETER name:acc index:0 type:T of .sum + VALUE_PARAMETER name:e index:1 type:T of .sum + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (acc: T of .sum, e: T of .sum): T of .sum declared in .sum' + CALL 'public abstract fun combine (other: T of .Monoid): T of .Monoid [fake_override,infix] declared in .Monoid' type=T of .sum origin=null + $this: GET_VAR ': .Monoid.sum> declared in .sum' type=.Monoid.sum> origin=null + $receiver: GET_VAR 'acc: T of .sum declared in .sum.' type=T of .sum origin=null + other: GET_VAR 'e: T of .sum declared in .sum.' type=T of .sum origin=null + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : .IntMonoid + : kotlin.Int + receiver: GET_OBJECT 'CLASS OBJECT name:IntMonoid modality:FINAL visibility:public superTypes:[.Monoid]' type=.IntMonoid + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.IntMonoid, kotlin.Int> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.IntMonoid) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:.IntMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .box' + CALL 'public final fun sum (: .Monoid.sum>): T of .sum declared in ' type=kotlin.Int origin=null + : kotlin.Int + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.Int + elements: VARARG type=kotlin.Array varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + CONST Int type=kotlin.Int value=2 + CONST Int type=kotlin.Int value=3 + : GET_VAR '$this$with: .IntMonoid declared in .box.' type=.IntMonoid origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.String origin=null + : .StringMonoid + : kotlin.String + receiver: GET_OBJECT 'CLASS OBJECT name:StringMonoid modality:FINAL visibility:public superTypes:[.Monoid]' type=.StringMonoid + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.StringMonoid, kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.StringMonoid) returnType:kotlin.String + $receiver: VALUE_PARAMETER name:$this$with type:.StringMonoid + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .box' + CALL 'public final fun sum (: .Monoid.sum>): T of .sum declared in ' type=kotlin.String origin=null + : kotlin.String + $receiver: CALL 'public final fun listOf (vararg elements: T of kotlin.collections.CollectionsKt.listOf): kotlin.collections.List declared in kotlin.collections.CollectionsKt' type=kotlin.collections.List origin=null + : kotlin.String + elements: VARARG type=kotlin.Array varargElementType=kotlin.String + CONST String type=kotlin.String value="O" + CONST String type=kotlin.String value="K" + : GET_VAR '$this$with: .StringMonoid declared in .box.' type=.StringMonoid origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/function.ir.txt new file mode 100644 index 00000000000..b3d2a22133a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.ir.txt @@ -0,0 +1,50 @@ +FILE fqName: fileName:/function.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:foo visibility:public modality:FINAL <> (:.C) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .foo' type=.C origin=null + FUN name:bar visibility:public modality:FINAL <> (c:.C) returnType:kotlin.Unit + VALUE_PARAMETER name:c index:0 type:.C + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .C + : kotlin.Unit + receiver: GET_VAR 'c: .C declared in .bar' type=.C origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.C + BLOCK_BODY + CALL 'public final fun foo (: .C): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : GET_VAR '$this$with: .C declared in .bar.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.kt b/compiler/testData/ir/irText/declarations/contextReceivers/function.kt new file mode 100644 index 00000000000..4d59b377438 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.kt @@ -0,0 +1,17 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +class C { + val c = 42 +} + +context(C) +fun foo() { + c +} + +fun bar(c: C) { + with(c) { + foo() + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/function.kt.txt new file mode 100644 index 00000000000..a24bd398adb --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.kt.txt @@ -0,0 +1,23 @@ +class C { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val c: Int + field = 42 + get + +} + +fun foo(: C) { + .() /*~> Unit */ +} + +fun bar(c: C) { + with(receiver = c, block = local fun C.() { + foo( = $this$with) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/function.txt b/compiler/testData/ir/irText/declarations/contextReceivers/function.txt new file mode 100644 index 00000000000..b3d2a22133a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/function.txt @@ -0,0 +1,50 @@ +FILE fqName: fileName:/function.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:foo visibility:public modality:FINAL <> (:.C) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .foo' type=.C origin=null + FUN name:bar visibility:public modality:FINAL <> (c:.C) returnType:kotlin.Unit + VALUE_PARAMETER name:c index:0 type:.C + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .C + : kotlin.Unit + receiver: GET_VAR 'c: .C declared in .bar' type=.C origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.C + BLOCK_BODY + CALL 'public final fun foo (: .C): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : GET_VAR '$this$with: .C declared in .bar.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt new file mode 100644 index 00000000000..f2d8dd0f622 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.ir.txt @@ -0,0 +1,244 @@ +FILE fqName: fileName:/functionalType.kt + CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Param + CONSTRUCTOR visibility:public <> () returnType:.Param [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Param modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> () returnType:.C [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:R modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.R + CONSTRUCTOR visibility:public <> () returnType:.R [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:R modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:r visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:r type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + CONST Int type=kotlin.Int value=42 + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.R) returnType:kotlin.Int + correspondingProperty: PROPERTY name:r visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.R + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .R' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:r type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .R declared in .R.' type=.R origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f1 visibility:public modality:FINAL <> ($receiver:.R, :.C, g:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.R + VALUE_PARAMETER name: index:0 type:.C + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function3, p2: P2 of kotlin.Function3, p3: P3 of kotlin.Function3): R of kotlin.Function3 [operator] declared in kotlin.Function3' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> declared in .f1' type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .C declared in .f1' type=.C origin=null + p2: GET_VAR ': .R declared in .f1' type=.R origin=null + p3: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:f2 visibility:public modality:FINAL <> (:.C, g:@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit>) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.C + VALUE_PARAMETER name:g index:1 type:@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> declared in .f2' type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .C declared in .f2' type=.C origin=null + p2: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Param' type=.Param origin=null + FUN name:f3 visibility:public modality:FINAL <> ($receiver:.R, :.C, g:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.R + VALUE_PARAMETER name: index:0 type:.C + VALUE_PARAMETER name:g index:1 type:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: @[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> declared in .f3' type=@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .C declared in .f3' type=.C origin=null + p2: GET_VAR ': .R declared in .f3' type=.R origin=null + FUN name:f4 visibility:public modality:FINAL <> (:.C, g:@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit>) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.C + VALUE_PARAMETER name:g index:1 type:@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> + BLOCK_BODY + CALL 'public abstract fun invoke (p1: P1 of kotlin.Function1): R of kotlin.Function1 [operator] declared in kotlin.Function1' type=kotlin.Unit origin=INVOKE + $this: GET_VAR 'g: @[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> declared in .f4' type=@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> origin=VARIABLE_AS_FUNCTION + p1: GET_VAR ': .C declared in .f4' type=.C origin=null + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:lf1 type:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function3<.C, .R, .Param, kotlin.Unit> [val] + 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$null type:.R + VALUE_PARAMETER name: index:0 type:.C + VALUE_PARAMETER name:$noName_0 index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$null: .R declared in .test.' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .test.' type=.C origin=null + VAR name:lf2 type:@[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .Param, kotlin.Unit> [val] + 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 + VALUE_PARAMETER name:$noName_0 index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .test.' type=.C origin=null + VAR name:lf3 type:@[ExtensionFunctionType] @[ContextFunctionTypeParams(count = '1')] kotlin.Function2<.C, .R, kotlin.Unit> [val] + 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$null type:.R + VALUE_PARAMETER name: index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$null: .R declared in .test.' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .test.' type=.C origin=null + VAR name:lf4 type:@[ContextFunctionTypeParams(count = '1')] kotlin.Function1<.C, kotlin.Unit> [val] + 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 + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .test.' type=.C origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .C + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .C' type=.C origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.C, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.C) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.C + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .R + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .R' type=.R origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.R, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.R) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.R + BLOCK_BODY + CALL 'public final fun f1 (: .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 + 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 + 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 + VALUE_PARAMETER name: index:0 type:.C + VALUE_PARAMETER name:$noName_0 index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$f1: .R declared in .test...' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + CALL 'public final fun f2 (: .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 + 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 + 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 + VALUE_PARAMETER name:$noName_0 index:1 type:.Param + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + CALL 'public final fun f3 (: .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 + 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 + 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 + VALUE_PARAMETER name: index:0 type:.C + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .R' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$f3: .R declared in .test...' type=.R origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null + CALL 'public final fun f4 (: .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 + 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 + 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 + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR '$this$with: .C declared in .test.' type=.C origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt new file mode 100644 index 00000000000..8e2ba41675b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt @@ -0,0 +1,73 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +class Param +class C { + val c = 42 +} +class R { + val r = 42 +} + +context(C) +fun R.f1(g: context(C) R.(Param) -> Unit) { + g(this@C, this@R, Param()) +} + +context(C) +fun f2(g: context(C) (Param) -> Unit) { + g(this@C, Param()) +} + +context(C) +fun R.f3(g: context(C) R.() -> Unit) { + g(this@C, this@R) +} + +context(C) +fun f4(g: context(C) () -> Unit) { + g(this@C) +} + +fun test() { + val lf1: context(C) R.(Param) -> Unit = { _ -> + r + c + } + val lf2: context(C) (Param) -> Unit = { _ -> + c + } + val lf3: context(C) R.() -> Unit = { + r + c + } + val lf4: context(C) () -> Unit = { + c + } + + with(C()) { + with(R()) { + f1(lf1) + f1 { _ -> + r + c + } + + f2(lf2) + f2 { _ -> + c + } + + f3(lf3) + f3 { + r + c + } + + f4(lf4) + f4 { + c + } + } + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt new file mode 100644 index 00000000000..2ab5782ce7a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt.txt @@ -0,0 +1,99 @@ +class Param { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class C { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val c: Int + field = 42 + get + +} + +class R { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + val r: Int + field = 42 + get + +} + +fun R.f1(: C, g: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3) { + g.invoke(p1 = , p2 = , p3 = Param()) +} + +fun f2(: C, g: @ContextFunctionTypeParams(count = 1) Function2) { + g.invoke(p1 = , p2 = Param()) +} + +fun R.f3(: C, g: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function2) { + g.invoke(p1 = , p2 = ) +} + +fun f4(: C, g: @ContextFunctionTypeParams(count = 1) Function1) { + g.invoke(p1 = ) +} + +fun test() { + val lf1: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function3 = local fun R.(: C, $noName_0: Param) { + $this$null.() /*~> Unit */ + .() /*~> Unit */ + } + + val lf2: @ContextFunctionTypeParams(count = 1) Function2 = local fun (: C, $noName_0: Param) { + .() /*~> Unit */ + } + + val lf3: @ExtensionFunctionType @ContextFunctionTypeParams(count = 1) Function2 = local fun R.(: C) { + $this$null.() /*~> Unit */ + .() /*~> Unit */ + } + + val lf4: @ContextFunctionTypeParams(count = 1) Function1 = local fun (: C) { + .() /*~> Unit */ + } + + 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$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) { + $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$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) { + $this$with.() /*~> Unit */ + } +) + } +) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt new file mode 100644 index 00000000000..2c2b68a37dd --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.ir.txt @@ -0,0 +1,53 @@ +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?] + CONSTRUCTOR visibility:public <> () returnType:.A.A> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + 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?] + CONSTRUCTOR visibility:public <> () returnType:.B

.B> [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' + 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 () [primary] declared in .A' type=.A origin=null + : kotlin.Int + FUN name:bar visibility:public modality:FINAL <> ($receiver:kotlin.collections.Collection) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:kotlin.collections.Collection + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONSTRUCTOR_CALL 'public constructor () [primary] declared in .B' type=.B origin=null + : kotlin.Int diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt new file mode 100644 index 00000000000..4336b94350c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.fir.kt.txt @@ -0,0 +1,25 @@ +class A { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +class B

{ + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +fun Int.foo() { + A() /*~> Unit */ +} + +fun Collection.bar() { + B() /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt new file mode 100644 index 00000000000..6b1b460f187 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.ir.txt @@ -0,0 +1,65 @@ +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?] + 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 + 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 + 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?] + 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> + 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 + 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 (: 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 + 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 + : kotlin.Int + : 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 new file mode 100644 index 00000000000..0507c9ffb8d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +ContextReceivers + +context(T) class A + +context(Collection

) class B

+ +fun Int.foo() { + A() +} + +fun Collection.bar() { + B() +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt new file mode 100644 index 00000000000..7e807299313 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt.txt @@ -0,0 +1,29 @@ +class A { + private /* final field */ val contextReceiverField0: T + constructor(: T) /* primary */ { + super/*Any*/() + .#contextReceiverField0 = + /* () */ + + } + +} + +class B

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

+ constructor(: Collection

) /* primary */ { + super/*Any*/() + .#contextReceiverField0 = + /* () */ + + } + +} + +fun Int.foo() { + A( = ) /*~> Unit */ +} + +fun Collection.bar() { + B( = ) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.ir.txt new file mode 100644 index 00000000000..b04bf2fe949 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.ir.txt @@ -0,0 +1,152 @@ +FILE fqName: fileName:/lazy.kt + CLASS INTERFACE name:Lazy modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Lazy.Lazy> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test1 visibility:public modality:FINAL <> (:.Lazy, :.Lazy) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.Lazy + VALUE_PARAMETER name: index:1 type:.Lazy + BLOCK_BODY + FUN name:test2 visibility:public modality:FINAL ($receiver:.Lazy, :.Lazy.test2>) returnType:kotlin.Unit + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Lazy + VALUE_PARAMETER name: index:0 type:.Lazy.test2> + BLOCK_BODY + FUN name:test3 visibility:public modality:FINAL ($receiver:.Lazy, :.Lazy<.Lazy.test3>>) returnType:kotlin.Unit + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + $receiver: VALUE_PARAMETER name: type:.Lazy + VALUE_PARAMETER name: index:0 type:.Lazy<.Lazy.test3>> + BLOCK_BODY + FUN name:f visibility:public modality:FINAL (lazy1:.Lazy, lazy2:.Lazy, lazyT:.Lazy.f>, lazyLazyT:.Lazy<.Lazy.f>>) returnType:kotlin.Unit + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:lazy1 index:0 type:.Lazy + VALUE_PARAMETER name:lazy2 index:1 type:.Lazy + VALUE_PARAMETER name:lazyT index:2 type:.Lazy.f> + VALUE_PARAMETER name:lazyLazyT index:3 type:.Lazy<.Lazy.f>> + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy2: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test1 (: .Lazy, : .Lazy): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + CALL 'public final fun test2 (: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.CharSequence + $receiver: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy2: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test1 (: .Lazy, : .Lazy): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + CALL 'public final fun test2 (: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.Int + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy.f> + : kotlin.Unit + receiver: GET_VAR 'lazyT: .Lazy.f> declared in .f' type=.Lazy.f> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy.f>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy.f>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy.f> + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test2 (: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.Int + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy<.Lazy.f>> + : kotlin.Unit + receiver: GET_VAR 'lazyLazyT: .Lazy<.Lazy.f>> declared in .f' type=.Lazy<.Lazy.f>> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy<.Lazy.f>>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy<.Lazy.f>>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy<.Lazy.f>> + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun test2 (: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : kotlin.Int + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + CALL 'public final fun test3 (: .Lazy<.Lazy.test3>>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : T of .f + $receiver: GET_VAR '$this$with: .Lazy declared in .f..' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy<.Lazy.f>> declared in .f.' type=.Lazy<.Lazy.f>> origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy + : kotlin.Unit + receiver: GET_VAR 'lazy1: .Lazy declared in .f' type=.Lazy origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy + BLOCK_BODY + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .Lazy<.Lazy.f>> + : kotlin.Unit + receiver: GET_VAR 'lazyLazyT: .Lazy<.Lazy.f>> declared in .f' type=.Lazy<.Lazy.f>> origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Lazy<.Lazy.f>>, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Lazy<.Lazy.f>>) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.Lazy<.Lazy.f>> + BLOCK_BODY + CALL 'public final fun test2 (: .Lazy.test2>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : .Lazy.f> + $receiver: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy<.Lazy.f>> declared in .f..' type=.Lazy<.Lazy.f>> origin=null + CALL 'public final fun test3 (: .Lazy<.Lazy.test3>>): kotlin.Unit declared in ' type=kotlin.Unit origin=null + : T of .f + $receiver: GET_VAR '$this$with: .Lazy declared in .f.' type=.Lazy origin=null + : GET_VAR '$this$with: .Lazy<.Lazy.f>> declared in .f..' type=.Lazy<.Lazy.f>> origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt new file mode 100644 index 00000000000..0c0a9276f55 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt @@ -0,0 +1,45 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +interface Lazy + +context(Lazy, Lazy) +fun test1() {} + +context(Lazy) +fun Lazy.test2() {} + +context(Lazy>) +fun Lazy.test3() {} + +fun f(lazy1: Lazy, lazy2: Lazy, lazyT: Lazy, lazyLazyT: Lazy>) { + with(lazy1) { + with(lazy2) { + test1() + test2() + } + } + with(lazy2) { + with(lazy1) { + test1() + test2() + } + } + with(lazyT) { + with(lazy1) { + test2() + } + } + with(lazyLazyT) { + with(lazy1) { + test2() + test3() + } + } + with(lazy1) { + with(lazyLazyT) { + test2() + test3() + } + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt.txt new file mode 100644 index 00000000000..762b8612d01 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt.txt @@ -0,0 +1,54 @@ +interface Lazy { + +} + +fun test1(: Lazy, : Lazy) { +} + +fun Lazy.test2(: Lazy) { +} + +fun Lazy.test3(: Lazy>) { +} + +fun f(lazy1: Lazy, lazy2: Lazy, lazyT: Lazy, lazyLazyT: Lazy>) { + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + with, Unit>(receiver = lazy2, block = local fun Lazy.() { + test1( = $this$with, = $this$with) + $this$with.test2( = $this$with) + } +) + } +) + with, Unit>(receiver = lazy2, block = local fun Lazy.() { + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + test1( = $this$with, = $this$with) + $this$with.test2( = $this$with) + } +) + } +) + with, Unit>(receiver = lazyT, block = local fun Lazy.() { + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + $this$with.test2( = $this$with) + } +) + } +) + with>, Unit>(receiver = lazyLazyT, block = local fun Lazy>.() { + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + $this$with.test2( = $this$with) + $this$with.test3( = $this$with) + } +) + } +) + with, Unit>(receiver = lazy1, block = local fun Lazy.() { + with>, Unit>(receiver = lazyLazyT, block = local fun Lazy>.() { + $this$with.test2>( = $this$with) + $this$with.test3( = $this$with) + } +) + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.ir.txt new file mode 100644 index 00000000000..1f61685fdd2 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.ir.txt @@ -0,0 +1,102 @@ +FILE fqName: fileName:/localDeclaration.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:f visibility:public modality:OPEN <> ($this:.A) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.A + BLOCK_BODY + 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:[.A] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + CONSTRUCTOR visibility:public <> () returnType:.B [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[.A]' + FUN FAKE_OVERRIDE name:f visibility:public modality:OPEN <> ($this:.A) returnType:kotlin.Unit [fake_override] + overridden: + public open fun f (): kotlin.Unit declared in .A + $this: VALUE_PARAMETER name: type:.A + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .A + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:testLocalFunction visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + FUN LOCAL_FUNCTION name:local visibility:local modality:FINAL <> (:.A) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.A + BLOCK_BODY + CALL 'public open fun f (): kotlin.Unit declared in .A' type=kotlin.Unit origin=null + $this: GET_VAR ': .A declared in .testLocalFunction.local' type=.A origin=null + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .B + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .B' type=.B origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.B, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.B) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.B + BLOCK_BODY + CALL 'local final fun local (: .A): kotlin.Unit declared in .testLocalFunction' type=kotlin.Unit origin=null + : GET_VAR '$this$with: .B declared in .testLocalFunction.' type=.B origin=null + FUN name:testLocalClass visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CLASS CLASS name:Local modality:FINAL visibility:local superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.testLocalClass.Local + FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.A visibility:private [final] + CONSTRUCTOR visibility:public <> (:.A) returnType:.testLocalClass.Local [primary] + VALUE_PARAMETER name: index:0 type:.A + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + SET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.A visibility:private [final]' type=kotlin.Unit origin=null + receiver: GET_VAR ': .testLocalClass.Local declared in .testLocalClass.Local' type=.testLocalClass.Local origin=null + value: GET_VAR ': .A declared in .testLocalClass.Local.' type=.A origin=null + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Local modality:FINAL visibility:local superTypes:[kotlin.Any]' + FUN name:local visibility:public modality:FINAL <> ($this:.testLocalClass.Local) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.testLocalClass.Local + BLOCK_BODY + CALL 'public open fun f (): kotlin.Unit declared in .A' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD FIELD_FOR_CLASS_CONTEXT_RECEIVER name:contextReceiverField0 type:.A visibility:private [final]' type=.A origin=null + receiver: GET_VAR ': .testLocalClass.Local declared in .testLocalClass.Local.local' type=.testLocalClass.Local 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 + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Unit origin=null + : .B + : kotlin.Unit + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .B' type=.B origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.B, kotlin.Unit> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.B) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name:$this$with type:.B + BLOCK_BODY + CALL 'public final fun local (): kotlin.Unit declared in .testLocalClass.Local' type=kotlin.Unit origin=null + $this: CONSTRUCTOR_CALL 'public constructor (: .A) [primary] declared in .testLocalClass.Local' type=.testLocalClass.Local origin=null + : GET_VAR '$this$with: .B declared in .testLocalClass.' type=.B origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt b/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt new file mode 100644 index 00000000000..df56b6e7025 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt @@ -0,0 +1,29 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +interface A { + fun f() {} +} +class B : A + +fun testLocalFunction() { + context(A) + fun local() { + f() + } + with(B()) { + local() + } +} + +fun testLocalClass() { + context(A) + class Local { + fun local() { + f() + } + } + with(B()) { + Local().local() + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt.txt new file mode 100644 index 00000000000..0d896315195 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt.txt @@ -0,0 +1,47 @@ +interface A { + fun f() { + } + +} + +class B : A { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +fun testLocalFunction() { + local fun local(: A) { + .f() + } + + with(receiver = B(), block = local fun B.() { + local( = $this$with) + } +) +} + +fun testLocalClass() { + local class Local { + private /* final field */ val contextReceiverField0: A + constructor(: A) /* primary */ { + super/*Any*/() + .#contextReceiverField0 = + /* () */ + + } + + fun local() { + .#contextReceiverField0.f() + } + + } + + with(receiver = B(), block = local fun B.() { + Local( = $this$with).local() + } +) +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.ir.txt new file mode 100644 index 00000000000..8ce484470f6 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.ir.txt @@ -0,0 +1,44 @@ +FILE fqName: fileName:/overloadPriority.kt + CLASS CLASS name:Context modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Context + CONSTRUCTOR visibility:public <> () returnType:.Context [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Context modality:FINAL visibility:public superTypes:[kotlin.Any]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL <> (:.Context) returnType:kotlin.String + VALUE_PARAMETER name: index:0 type:.Context + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (: .Context): kotlin.String declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + FUN name:f visibility:public modality:FINAL <> () returnType:kotlin.Any + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (): kotlin.Any declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : .Context + : kotlin.Int + receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Context' type=.Context origin=null + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1<.Context, kotlin.Int> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:.Context) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:.Context + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test' + CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public final fun f (: .Context): kotlin.String declared in ' type=kotlin.String origin=null + : GET_VAR '$this$with: .Context declared in .test.' type=.Context origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt new file mode 100644 index 00000000000..46817fbe7ef --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt @@ -0,0 +1,15 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +class Context + +context(Context) +fun f(): String = TODO() + +fun f(): Any = TODO() + +fun test() { + with(Context()) { + f().length + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt.txt new file mode 100644 index 00000000000..ce4cec63a55 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt.txt @@ -0,0 +1,23 @@ +class Context { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +fun f(: Context): String { + return TODO() +} + +fun f(): Any { + return TODO() +} + +fun test() { + with(receiver = Context(), block = local fun Context.(): Int { + return f( = $this$with).() + } +) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.ir.txt new file mode 100644 index 00000000000..68c8b999e7c --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.ir.txt @@ -0,0 +1,30 @@ +FILE fqName: fileName:/overloading.kt + FUN name:foo visibility:public modality:FINAL <> (:kotlin.Int, :kotlin.String) returnType:kotlin.Int + VALUE_PARAMETER name: index:0 type:kotlin.Int + VALUE_PARAMETER name: index:1 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (: kotlin.Int, : kotlin.String): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .foo' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=42 + FUN name:foo visibility:public modality:FINAL <> (:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER name: index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo (: kotlin.Int): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: GET_VAR ': kotlin.Int declared in .foo' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=42 + FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun with (receiver: T of kotlin.StandardKt.with, block: @[ExtensionFunctionType] kotlin.Function1): R of kotlin.StandardKt.with [inline] declared in kotlin.StandardKt' type=kotlin.Int origin=null + : kotlin.Int + : kotlin.Int + receiver: CONST Int type=kotlin.Int value=42 + block: FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function1 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:kotlin.Int) returnType:kotlin.Int + $receiver: VALUE_PARAMETER name:$this$with type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Int declared in .test' + CALL 'public final fun foo (: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null + : GET_VAR '$this$with: kotlin.Int declared in .test.' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt new file mode 100644 index 00000000000..aa0ba29e6f8 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +context(Int, String) +fun foo(): Int { + return this@Int + 42 +} + +context(Int) +fun foo(): Int { + return this@Int + 42 +} + +fun test() { + with(42) { + foo() + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt.txt new file mode 100644 index 00000000000..0ded1856899 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt.txt @@ -0,0 +1,14 @@ +fun foo(: Int, : String): Int { + return .plus(other = 42) +} + +fun foo(: Int): Int { + return .plus(other = 42) +} + +fun test() { + with(receiver = 42, block = local fun Int.(): Int { + return foo( = $this$with) + } +) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt new file mode 100644 index 00000000000..5e2659b3c16 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.ir.txt @@ -0,0 +1,58 @@ +FILE fqName: fileName:/plusMatrix.kt + CLASS INTERFACE name:NumberOperations modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.NumberOperations + FUN name:plus visibility:public modality:ABSTRACT <> ($this:.NumberOperations, $receiver:kotlin.Number, other:kotlin.Number) returnType:kotlin.Number + $this: VALUE_PARAMETER name: type:.NumberOperations + $receiver: VALUE_PARAMETER name: type:kotlin.Number + VALUE_PARAMETER name:other index:0 type:kotlin.Number + 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:Matrix modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Matrix + CONSTRUCTOR visibility:public <> () returnType:.Matrix [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Matrix 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:plus visibility:public modality:FINAL <> ($receiver:.Matrix, other:.Matrix) returnType:.Matrix + $receiver: VALUE_PARAMETER name: type:.Matrix + VALUE_PARAMETER name:other index:0 type:.Matrix + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun plus (other: .Matrix): .Matrix declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + FUN name:plusMatrix visibility:public modality:FINAL <> ($receiver:.NumberOperations, m1:.Matrix, m2:.Matrix) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.NumberOperations + VALUE_PARAMETER name:m1 index:0 type:.Matrix + VALUE_PARAMETER name:m2 index:1 type:.Matrix + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun plus (other: .Matrix): .Matrix declared in ' type=.Matrix origin=null + $receiver: GET_VAR 'm1: .Matrix declared in .plusMatrix' type=.Matrix origin=null + other: GET_VAR 'm2: .Matrix declared in .plusMatrix' type=.Matrix origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun plus (other: .Matrix): .Matrix declared in ' type=.Matrix origin=null + $receiver: GET_VAR 'm2: .Matrix declared in .plusMatrix' type=.Matrix origin=null + other: GET_VAR 'm1: .Matrix declared in .plusMatrix' type=.Matrix origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt new file mode 100644 index 00000000000..42c9efc2f8d --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.fir.kt.txt @@ -0,0 +1,22 @@ +interface NumberOperations { + abstract fun Number.plus(other: Number): Number + +} + +class Matrix { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +fun Matrix.plus(other: Matrix): Matrix { + return TODO() +} + +fun NumberOperations.plusMatrix(m1: Matrix, m2: Matrix) { + m1.plus(other = m2) /*~> Unit */ + m2.plus(other = m1) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt new file mode 100644 index 00000000000..deac4bfb978 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.ir.txt @@ -0,0 +1,63 @@ +FILE fqName: fileName:/plusMatrix.kt + CLASS INTERFACE name:NumberOperations modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.NumberOperations + FUN name:plus visibility:public modality:ABSTRACT <> ($this:.NumberOperations, $receiver:kotlin.Number, other:kotlin.Number) returnType:kotlin.Number + $this: VALUE_PARAMETER name: type:.NumberOperations + $receiver: VALUE_PARAMETER name: type:kotlin.Number + VALUE_PARAMETER name:other index:0 type:kotlin.Number + 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:Matrix modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Matrix + CONSTRUCTOR visibility:public <> () returnType:.Matrix [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Matrix 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:plus visibility:public modality:FINAL <> ($receiver:.Matrix, :.NumberOperations, other:.Matrix) returnType:.Matrix + $receiver: VALUE_PARAMETER name: type:.Matrix + VALUE_PARAMETER name: index:0 type:.NumberOperations + VALUE_PARAMETER name:other index:1 type:.Matrix + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun plus (: .NumberOperations, other: .Matrix): .Matrix declared in ' + CALL 'public final fun TODO (): kotlin.Nothing [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null + FUN name:plusMatrix visibility:public modality:FINAL <> ($receiver:.NumberOperations, m1:.Matrix, m2:.Matrix) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER name: type:.NumberOperations + VALUE_PARAMETER name:m1 index:0 type:.Matrix + VALUE_PARAMETER name:m2 index:1 type:.Matrix + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun plus (: .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 + 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 + other: GET_VAR 'm1: .Matrix declared in .plusMatrix' type=.Matrix origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt new file mode 100644 index 00000000000..dca4c87f458 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt @@ -0,0 +1,15 @@ +// !LANGUAGE: +ContextReceivers +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface NumberOperations { + fun Number.plus(other: Number): Number +} + +class Matrix + +context(NumberOperations) fun Matrix.plus(other: Matrix): Matrix = TODO() + +fun NumberOperations.plusMatrix(m1: Matrix, m2: Matrix) { + m1.plus(m2) + m2.plus(m1) +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt.txt new file mode 100644 index 00000000000..616755f8785 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt.txt @@ -0,0 +1,22 @@ +interface NumberOperations { + abstract fun Number.plus(other: Number): Number + +} + +class Matrix { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + +} + +fun Matrix.plus(: NumberOperations, other: Matrix): Matrix { + return TODO() +} + +fun NumberOperations.plusMatrix(m1: Matrix, m2: Matrix) { + m1.plus( = /*as Matrix */, other = m2) /*~> Unit */ + m2.plus( = /*as Matrix */, other = m1) /*~> Unit */ +} diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/property.ir.txt new file mode 100644 index 00000000000..5e6a4b042bf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.ir.txt @@ -0,0 +1,48 @@ +FILE fqName: fileName:/property.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:a visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.A + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:b visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.B + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:c visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> (:.B, :.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + VALUE_PARAMETER name: index:0 type:.B + VALUE_PARAMETER name: index:1 type:.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (: .B, : .A): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public abstract fun a (): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: TYPE_OP type=.A origin=IMPLICIT_CAST typeOperand=.A + GET_VAR ': .A declared in .' type=.B origin=null + other: CALL 'public abstract fun b (): kotlin.Int declared in .B' type=kotlin.Int origin=null + $this: GET_VAR ': .B declared in .' type=.B origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.kt b/compiler/testData/ir/irText/declarations/contextReceivers/property.kt new file mode 100644 index 00000000000..cde08f9b377 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +interface A { + fun a(): Int +} +interface B { + fun b(): Int +} + +context(A, B) +val c get() = a() + b() \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/property.kt.txt new file mode 100644 index 00000000000..b2625fe68f1 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.kt.txt @@ -0,0 +1,14 @@ +interface A { + abstract fun a(): Int + +} + +interface B { + abstract fun b(): Int + +} + +val c: Int + get(: B, : A): Int { + return /*as A */.a().plus(other = .b()) + } diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/property.txt b/compiler/testData/ir/irText/declarations/contextReceivers/property.txt new file mode 100644 index 00000000000..5e6a4b042bf --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/property.txt @@ -0,0 +1,48 @@ +FILE fqName: fileName:/property.kt + CLASS INTERFACE name:A modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A + FUN name:a visibility:public modality:ABSTRACT <> ($this:.A) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.A + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:B modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + FUN name:b visibility:public modality:ABSTRACT <> ($this:.B) returnType:kotlin.Int + $this: VALUE_PARAMETER name: type:.B + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:c visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> (:.B, :.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + VALUE_PARAMETER name: index:0 type:.B + VALUE_PARAMETER name: index:1 type:.A + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (: .B, : .A): kotlin.Int declared in ' + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=PLUS + $this: CALL 'public abstract fun a (): kotlin.Int declared in .A' type=kotlin.Int origin=null + $this: TYPE_OP type=.A origin=IMPLICIT_CAST typeOperand=.A + GET_VAR ': .A declared in .' type=.B origin=null + other: CALL 'public abstract fun b (): kotlin.Int declared in .B' type=kotlin.Int origin=null + $this: GET_VAR ': .B declared in .' type=.B origin=null diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.ir.txt b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.ir.txt new file mode 100644 index 00000000000..16cd862510f --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.ir.txt @@ -0,0 +1,141 @@ +FILE fqName: fileName:/thisWithCustomLabel.kt + CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.A.A> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + CONSTRUCTOR visibility:public <> (a:T of .A) returnType:.A.A> [primary] + VALUE_PARAMETER name:a index:0 type:T of .A + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:a visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:a type:T of .A visibility:private [final] + EXPRESSION_BODY + GET_VAR 'a: T of .A declared in .A.' type=T of .A origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.A.A>) returnType:T of .A + correspondingProperty: PROPERTY name:a visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.A.A> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): T of .A declared in .A' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:a type:T of .A visibility:private [final]' type=T of .A origin=null + receiver: GET_VAR ': .A.A> declared in .A.' type=.A.A> origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.B + CONSTRUCTOR visibility:public <> (b:kotlin.Any) returnType:.B [primary] + VALUE_PARAMETER name:b index:0 type:kotlin.Any + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:b visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Any visibility:private [final] + EXPRESSION_BODY + GET_VAR 'b: kotlin.Any declared in .B.' type=kotlin.Any origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.B) returnType:kotlin.Any + correspondingProperty: PROPERTY name:b visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.B + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .B' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:b type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + receiver: GET_VAR ': .B declared in .B.' type=.B origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (c:kotlin.Any) returnType:.C [primary] + VALUE_PARAMETER name:c index:0 type:kotlin.Any + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]' + PROPERTY name:c visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Any visibility:private [final] + EXPRESSION_BODY + GET_VAR 'c: kotlin.Any declared in .C.' type=kotlin.Any origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.C) returnType:kotlin.Any + correspondingProperty: PROPERTY name:c visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Any declared in .C' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:c type:kotlin.Any visibility:private [final]' type=kotlin.Any origin=null + receiver: GET_VAR ': .C declared in .C.' type=.C origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:f visibility:public modality:FINAL <> (:.A, :.A, :.B) returnType:kotlin.Unit + VALUE_PARAMETER name: index:0 type:.A + VALUE_PARAMETER name: index:1 type:.A + VALUE_PARAMETER name: index:2 type:.B + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun toFloat (): kotlin.Float declared in kotlin.Int' type=kotlin.Float origin=null + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .f' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .f' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .B declared in .f' type=.B origin=null + PROPERTY name:p visibility:public modality:FINAL [val] + FUN name: visibility:public modality:FINAL <> ($receiver:.C, :.B, :.A, :.A) returnType:kotlin.Int + correspondingProperty: PROPERTY name:p visibility:public modality:FINAL [val] + $receiver: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name: index:0 type:.B + VALUE_PARAMETER name: index:1 type:.A + VALUE_PARAMETER name: index:2 type:.A + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun toFloat (): kotlin.Float declared in kotlin.Int' type=kotlin.Float origin=null + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public open fun (): kotlin.Int declared in kotlin.String' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'public final fun (): T of .A declared in .A' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': .A declared in .' type=.A origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .B' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .B declared in .' type=.B origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .C' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .' type=.C origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .C' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .' type=.C origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun (): kotlin.Any declared in .C' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR ': .C declared in .' type=.C origin=null + RETURN type=kotlin.Nothing from='public final fun (: .B, : .A, : .A): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt new file mode 100644 index 00000000000..9ae178123e7 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: +ContextReceivers +// IGNORE_BACKEND_FIR: JVM_IR + +class A(val a: T) +class B(val b: Any) +class C(val c: Any) + +context(labelAInt@A, A, labelB@B) fun f() { + this@labelAInt.a.toFloat() + this@A.a.length + this@labelB.b +} + +context(labelAInt@A, A, labelB@B) val C.p: Int + get() { + this@labelAInt.a.toFloat() + this@A.a.length + this@labelB.b + this@C.c + this@p.c + this.c + return 1 + } \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt.txt b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt.txt new file mode 100644 index 00000000000..23c5c9905d8 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt.txt @@ -0,0 +1,55 @@ +class A { + constructor(a: T) /* primary */ { + super/*Any*/() + /* () */ + + } + + val a: T + field = a + get + +} + +class B { + constructor(b: Any) /* primary */ { + super/*Any*/() + /* () */ + + } + + val b: Any + field = b + get + +} + +class C { + constructor(c: Any) /* primary */ { + super/*Any*/() + /* () */ + + } + + val c: Any + field = c + get + +} + +fun f(: A, : A, : B) { + .().toFloat() /*~> Unit */ + .().() /*~> Unit */ + .() /*~> Unit */ +} + +val C.p: Int + get(: B, : A, : A): Int { + .().toFloat() /*~> Unit */ + .().() /*~> Unit */ + .() /*~> Unit */ + .() /*~> Unit */ + .() /*~> Unit */ + .() /*~> Unit */ + return 1 + } 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 f69bb796617..fba43d92c10 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 @@ -742,6 +742,122 @@ public class IrTextTestGenerated extends AbstractIrTextTest { } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers") + @TestDataPath("$PROJECT_ROOT") + public class ContextReceivers { + @Test + public void testAllFilesPresentInContextReceivers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("class.kt") + public void testClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/class.kt"); + } + + @Test + @TestMetadata("function.kt") + public void testFunction() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/function.kt"); + } + + @Test + @TestMetadata("functionalType.kt") + public void testFunctionalType() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt"); + } + + @Test + @TestMetadata("genericOuterClass.kt") + public void testGenericOuterClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt"); + } + + @Test + @TestMetadata("lazy.kt") + public void testLazy() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt"); + } + + @Test + @TestMetadata("localDeclaration.kt") + public void testLocalDeclaration() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt"); + } + + @Test + @TestMetadata("overloadPriority.kt") + public void testOverloadPriority() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt"); + } + + @Test + @TestMetadata("overloading.kt") + public void testOverloading() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt"); + } + + @Test + @TestMetadata("plusMatrix.kt") + public void testPlusMatrix() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt"); + } + + @Test + @TestMetadata("property.kt") + public void testProperty() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/property.kt"); + } + + @Test + @TestMetadata("thisWithCustomLabel.kt") + public void testThisWithCustomLabel() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt"); + } + + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + public class FromKEEP { + @Test + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("canvas.kt") + public void testCanvas() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/canvas.kt"); + } + + @Test + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/compareTo.kt"); + } + + @Test + @TestMetadata("dp.kt") + public void testDp() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/dp.kt"); + } + + @Test + @TestMetadata("functionalType.kt") + public void testFunctionalType() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/functionalType.kt"); + } + + @Test + @TestMetadata("monoidSum.kt") + public void testMonoidSum() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP/monoidSum.kt"); + } + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/multiplatform") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt index 7f34a4719f8..d1a88159676 100644 --- a/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt +++ b/compiler/tests-compiler-utils/tests/org/jetbrains/kotlin/ir/IrVerifier.kt @@ -115,7 +115,21 @@ class IrVerifier(private val assertions: Assertions) : IrElementVisitorVoid { } - val declaredValueParameters = declaration.valueParameters.map { it.descriptor } + val expectedContextReceivers = functionDescriptor.contextReceiverParameters + val actualContextReceivers = + declaration.valueParameters.take(declaration.contextReceiverParametersCount).map { it.descriptor } + if (expectedContextReceivers.size != actualContextReceivers.size) { + error("$functionDescriptor: Context receivers mismatch: $expectedContextReceivers != $actualContextReceivers") + } else { + expectedContextReceivers.zip(actualContextReceivers).forEach { (expectedContextReceiver, actualContextReceiver) -> + require(expectedContextReceiver == actualContextReceiver) { + "$functionDescriptor: Context receivers mismatch: $expectedContextReceiver != $actualContextReceiver" + } + } + } + + val declaredValueParameters = + declaration.valueParameters.drop(declaration.contextReceiverParametersCount).map { it.descriptor } val actualValueParameters = functionDescriptor.valueParameters if (declaredValueParameters.size != actualValueParameters.size) { error("$functionDescriptor: Value parameters mismatch: $declaredValueParameters != $actualValueParameters") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java index b97989fdddd..4c9f71da362 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/ir/KlibTextTestCaseGenerated.java @@ -591,6 +591,87 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase { } } + @TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ContextReceivers extends AbstractKlibTextTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInContextReceivers() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/contextReceivers"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("class.kt") + public void testClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/class.kt"); + } + + @TestMetadata("function.kt") + public void testFunction() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/function.kt"); + } + + @TestMetadata("functionalType.kt") + public void testFunctionalType() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/functionalType.kt"); + } + + @TestMetadata("genericOuterClass.kt") + public void testGenericOuterClass() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/genericOuterClass.kt"); + } + + @TestMetadata("lazy.kt") + public void testLazy() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/lazy.kt"); + } + + @TestMetadata("localDeclaration.kt") + public void testLocalDeclaration() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/localDeclaration.kt"); + } + + @TestMetadata("overloadPriority.kt") + public void testOverloadPriority() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/overloadPriority.kt"); + } + + @TestMetadata("overloading.kt") + public void testOverloading() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/overloading.kt"); + } + + @TestMetadata("plusMatrix.kt") + public void testPlusMatrix() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/plusMatrix.kt"); + } + + @TestMetadata("property.kt") + public void testProperty() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/property.kt"); + } + + @TestMetadata("thisWithCustomLabel.kt") + public void testThisWithCustomLabel() throws Exception { + runTest("compiler/testData/ir/irText/declarations/contextReceivers/thisWithCustomLabel.kt"); + } + + @TestMetadata("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class FromKEEP extends AbstractKlibTextTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInFromKEEP() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/contextReceivers/fromKEEP"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } + } + @TestMetadata("compiler/testData/ir/irText/declarations/multiplatform") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)