diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt index 1f9eab39dac..322374610c7 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrConverter.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.backend +import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.KtPsiSourceFileLinesMapping import org.jetbrains.kotlin.KtSourceFileLinesMappingFromLineStartOffsets import org.jetbrains.kotlin.builtins.DefaultBuiltIns @@ -250,11 +251,17 @@ class Fir2IrConverter( } } - // Sort declarations so that all non-synthetic declarations are before synthetic ones. + // Sort declarations so that all non-synthetic declarations and `synthetic class delegation fields` are before other synthetic ones. // This is needed because converting synthetic fields for implementation delegation needs to know // existing declarations in the class to avoid adding redundant delegated members. private fun syntheticPropertiesLast(declarations: Iterable): Iterable { - return declarations.sortedBy { it !is FirField && it.isSynthetic } + return declarations.sortedBy { + when { + !it.isSynthetic -> false + it.source?.kind is KtFakeSourceElementKind.ClassDelegationField -> false + else -> true + } + } } private fun registerClassAndNestedClasses(klass: FirClass, parent: IrDeclarationParent): IrClass { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index 8d49b3c73c1..ae9b698a43f 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -972,6 +972,28 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + public class Delegate { + @Test + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @Test + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index c908a0b548a..7e0a84bf23b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -972,6 +972,28 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + public class Delegate { + @Test + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @Test + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.ir.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.ir.txt new file mode 100644 index 00000000000..84a50a5d160 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.ir.txt @@ -0,0 +1,204 @@ +FILE fqName:foo fileName:/delegationEvaluationOrder1.kt + CLASS INTERFACE name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base + FUN name:foo visibility:public modality:ABSTRACT <> ($this:foo.Base, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:foo.Base + VALUE_PARAMETER name:x index:0 type:kotlin.String + 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 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:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.BaseImpl + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:foo.BaseImpl [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in foo.BaseImpl.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.BaseImpl) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.BaseImpl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.BaseImpl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.' type=foo.BaseImpl origin=null + FUN name:foo visibility:public modality:OPEN <> ($this:foo.BaseImpl, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.BaseImpl + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.BaseImpl' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Base: " + CALL 'public final fun (): kotlin.String declared in foo.BaseImpl' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.foo' type=foo.BaseImpl origin=null + CONST String type=kotlin.String value=":" + GET_VAR 'x: kotlin.String declared in foo.BaseImpl.foo' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + $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 foo.Base + $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 foo.Base + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:global visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.String declared in foo.' type=kotlin.String origin=null + CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.DerivedBase + CONSTRUCTOR visibility:public <> () returnType:foo.DerivedBase [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any]' + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":DerivedBase" + 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 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:newBase visibility:public modality:FINAL <> () returnType:foo.Base + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":newBase" + RETURN type=kotlin.Nothing from='public final fun newBase (): foo.Base declared in foo' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) declared in foo.BaseImpl' type=foo.BaseImpl origin=null + s: CONST String type=kotlin.String value="test" + CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived + CONSTRUCTOR visibility:public <> () returnType:foo.Derived [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived declared in foo.Derived.foo' type=foo.Derived origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.DerivedBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + $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 foo.DerivedBase + public open fun hashCode (): kotlin.Int declared in foo.Base + $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 foo.DerivedBase + public open fun toString (): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived1 + CONSTRUCTOR visibility:public <> () returnType:foo.Derived1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived1, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived1 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived1' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived1 declared in foo.Derived1.foo' type=foo.Derived1 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived1.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.DerivedBase + $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 foo.Base + public open fun hashCode (): kotlin.Int declared in foo.DerivedBase + $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 foo.Base + public open fun toString (): kotlin.String declared in foo.DerivedBase + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:d type:foo.Derived [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived' type=foo.Derived origin=null + VAR name:d1 type:foo.Derived1 [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived1' type=foo.Derived1 origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in foo' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.kt.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.kt.txt new file mode 100644 index 00000000000..ed390a4a4c8 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.fir.kt.txt @@ -0,0 +1,89 @@ +package foo + +interface Base { + abstract fun foo(x: String): String + +} + +class BaseImpl : Base { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: String + field = s + get + + override fun foo(x: String): String { + return "Base: " + .() + ":" + x + } + +} + +var global: String + field = "" + get + set + +open class DerivedBase { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + init { + ( = ().plus(other = ":DerivedBase")) + } + +} + +fun newBase(): Base { + ( = ().plus(other = ":newBase")) + return BaseImpl(s = "test") +} + +class Derived : DerivedBase, Base { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_0: Base = newBase() + init { + ( = ().plus(other = ":Derived")) + } + +} + +class Derived1 : Base, DerivedBase { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_0: Base = newBase() + init { + ( = ().plus(other = ":Derived")) + } + +} + +fun box(): String { + var d: Derived = Derived() + var d1: Derived1 = Derived1() + return "OK" +} + diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.ir.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.ir.txt new file mode 100644 index 00000000000..f2a3e762d55 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.ir.txt @@ -0,0 +1,208 @@ +FILE fqName:foo fileName:/delegationEvaluationOrder1.kt + CLASS INTERFACE name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base + FUN name:foo visibility:public modality:ABSTRACT <> ($this:foo.Base, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:foo.Base + VALUE_PARAMETER name:x index:0 type:kotlin.String + 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 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:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.BaseImpl + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:foo.BaseImpl [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in foo.BaseImpl.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.BaseImpl) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.BaseImpl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.BaseImpl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.' type=foo.BaseImpl origin=null + FUN name:foo visibility:public modality:OPEN <> ($this:foo.BaseImpl, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.BaseImpl + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.BaseImpl' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Base: " + CALL 'public final fun (): kotlin.String declared in foo.BaseImpl' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.foo' type=foo.BaseImpl origin=null + CONST String type=kotlin.String value=":" + GET_VAR 'x: kotlin.String declared in foo.BaseImpl.foo' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + $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 foo.Base + $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 foo.Base + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:global visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.String declared in foo.' type=kotlin.String origin=null + CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.DerivedBase + CONSTRUCTOR visibility:public <> () returnType:foo.DerivedBase [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any]' + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":DerivedBase" + 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 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:newBase visibility:public modality:FINAL <> () returnType:foo.Base + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":newBase" + RETURN type=kotlin.Nothing from='public final fun newBase (): foo.Base declared in foo' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) declared in foo.BaseImpl' type=foo.BaseImpl origin=null + s: CONST String type=kotlin.String value="test" + CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived + CONSTRUCTOR visibility:public <> () returnType:foo.Derived [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base]' + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived declared in foo.Derived.foo' type=foo.Derived origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived.foo' type=kotlin.String origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.DerivedBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + $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 foo.DerivedBase + public open fun hashCode (): kotlin.Int declared in foo.Base + $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 foo.DerivedBase + public open fun toString (): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived1 + CONSTRUCTOR visibility:public <> () returnType:foo.Derived1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase]' + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived1, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived1 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived1' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived1 declared in foo.Derived1.foo' type=foo.Derived1 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived1.foo' type=kotlin.String origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.DerivedBase + $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 foo.Base + public open fun hashCode (): kotlin.Int declared in foo.DerivedBase + $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 foo.Base + public open fun toString (): kotlin.String declared in foo.DerivedBase + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:d type:foo.Derived [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived' type=foo.Derived origin=null + VAR name:d1 type:foo.Derived1 [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived1' type=foo.Derived1 origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in foo' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt new file mode 100644 index 00000000000..5286a3ace9a --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt @@ -0,0 +1,41 @@ +package foo + +interface Base { + abstract fun foo(x: String): String +} + +class BaseImpl(val s: String) : Base { + override fun foo(x: String): String = "Base: ${s}:${x}" +} + +var global = "" + +open class DerivedBase() { + init { + global += ":DerivedBase" + } +} + +fun newBase(): Base { + global += ":newBase" + return BaseImpl("test") +} + +class Derived() : DerivedBase(), Base by newBase() { + init { + global += ":Derived" + } +} + +class Derived1() : Base by newBase(), DerivedBase() { + init { + global += ":Derived" + } +} + +fun box(): String { + var d = Derived() + var d1 = Derived1() + + return "OK" +} diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt.txt new file mode 100644 index 00000000000..44d0e127d72 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt.txt @@ -0,0 +1,96 @@ +package foo + +interface Base { + abstract fun foo(x: String): String + +} + +class BaseImpl : Base { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: String + field = s + get + + override fun foo(x: String): String { + return "Base: " + .() + ":" + x + } + +} + +var global: String + field = "" + get + set + +open class DerivedBase { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + init { + { // BLOCK + ( = ().plus(other = ":DerivedBase")) + } + } + +} + +fun newBase(): Base { + { // BLOCK + ( = ().plus(other = ":newBase")) + } + return BaseImpl(s = "test") +} + +class Derived : DerivedBase, Base { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + init { + { // BLOCK + ( = ().plus(other = ":Derived")) + } + } + +} + +class Derived1 : Base, DerivedBase { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + init { + { // BLOCK + ( = ().plus(other = ":Derived")) + } + } + +} + +fun box(): String { + var d: Derived = Derived() + var d1: Derived1 = Derived1() + return "OK" +} diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.sig.kt.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.sig.kt.txt new file mode 100644 index 00000000000..0887140c049 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.sig.kt.txt @@ -0,0 +1,168 @@ +package foo + +// CHECK: +// Mangled name: foo{}global +// Public signature: foo/global|4288684431328455501[0] +// Public signature debug description: {}global +var global: String + // CHECK JVM_IR: + // Mangled name: foo#(){}kotlin.String + // Public signature: foo/global.|-6997244913903542523[0] + // Public signature debug description: (){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo#(){} + // Public signature: foo/global.|7627852862574367240[0] + // Public signature debug description: (){} + get + // CHECK: + // Mangled name: foo#(kotlin.String){} + // Public signature: foo/global.|5315586845372819266[0] + // Public signature debug description: (kotlin.String){} + set + +// CHECK: +// Mangled name: foo.BaseImpl +// Public signature: foo/BaseImpl|null[0] +class BaseImpl : Base { + // CHECK: + // Mangled name: foo.BaseImpl{}s + // Public signature: foo/BaseImpl.s|7217541905509134881[0] + // Public signature debug description: {}s + val s: String + // CHECK JVM_IR: + // Mangled name: foo.BaseImpl#(){}kotlin.String + // Public signature: foo/BaseImpl.s.|4142379646177092803[0] + // Public signature debug description: (){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.BaseImpl#(){} + // Public signature: foo/BaseImpl.s.|-1662172381559511151[0] + // Public signature debug description: (){} + get + + // CHECK: + // Mangled name: foo.BaseImpl#(kotlin.String){} + // Public signature: foo/BaseImpl.|1280618353163213788[0] + // Public signature debug description: (kotlin.String){} + constructor(s: String) /* primary */ + + // CHECK JVM_IR: + // Mangled name: foo.BaseImpl#foo(kotlin.String){}kotlin.String + // Public signature: foo/BaseImpl.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.BaseImpl#foo(kotlin.String){} + // Public signature: foo/BaseImpl.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.Derived +// Public signature: foo/Derived|null[0] +class Derived : DerivedBase, Base { + // CHECK: + // Mangled name: foo.Derived#(){} + // Public signature: foo/Derived.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + // CHECK JVM_IR: + // Mangled name: foo.Derived.$$delegate_0 + // Public signature: foo/Derived.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived.$$delegate_0 + // Public signature: foo/Derived.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_0: Base + // CHECK JVM_IR: + // Mangled name: foo.Derived#foo(kotlin.String){}kotlin.String + // Public signature: foo/Derived.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived#foo(kotlin.String){} + // Public signature: foo/Derived.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.Derived1 +// Public signature: foo/Derived1|null[0] +class Derived1 : DerivedBase, Base { + // CHECK: + // Mangled name: foo.Derived1#(){} + // Public signature: foo/Derived1.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + // CHECK JVM_IR: + // Mangled name: foo.Derived1.$$delegate_0 + // Public signature: foo/Derived1.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived1.$$delegate_0 + // Public signature: foo/Derived1.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_0: Base + // CHECK JVM_IR: + // Mangled name: foo.Derived1#foo(kotlin.String){}kotlin.String + // Public signature: foo/Derived1.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived1#foo(kotlin.String){} + // Public signature: foo/Derived1.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.DerivedBase +// Public signature: foo/DerivedBase|null[0] +open class DerivedBase { + // CHECK: + // Mangled name: foo.DerivedBase#(){} + // Public signature: foo/DerivedBase.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + +} + +// CHECK: +// Mangled name: foo.Base +// Public signature: foo/Base|null[0] +interface Base { + + // CHECK JVM_IR: + // Mangled name: foo.Base#foo(kotlin.String){}kotlin.String + // Public signature: foo/Base.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Base#foo(kotlin.String){} + // Public signature: foo/Base.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + abstract fun foo(x: String): String + +} + +// CHECK JVM_IR: +// Mangled name: foo#box(){}kotlin.String +// Public signature: foo/box|-9347091776561469[0] +// Public signature debug description: box(){}kotlin.String +// CHECK JS_IR NATIVE: +// Mangled name: foo#box(){} +// Public signature: foo/box|2173511048851971368[0] +// Public signature debug description: box(){} +fun box(): String + +// CHECK JVM_IR: +// Mangled name: foo#newBase(){}foo.Base +// Public signature: foo/newBase|4074800280318487147[0] +// Public signature debug description: newBase(){}foo.Base +// CHECK JS_IR NATIVE: +// Mangled name: foo#newBase(){} +// Public signature: foo/newBase|-6094796879594303932[0] +// Public signature debug description: newBase(){} +fun newBase(): Base + diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.fir.ir.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.fir.ir.txt new file mode 100644 index 00000000000..51e5d154df5 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.fir.ir.txt @@ -0,0 +1,370 @@ +FILE fqName:foo fileName:/delegationEvaluationOrder2.kt + CLASS INTERFACE name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base + FUN name:foo visibility:public modality:ABSTRACT <> ($this:foo.Base, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:foo.Base + VALUE_PARAMETER name:x index:0 type:kotlin.String + 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 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:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.BaseImpl + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:foo.BaseImpl [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in foo.BaseImpl.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.BaseImpl) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.BaseImpl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.BaseImpl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.' type=foo.BaseImpl origin=null + FUN name:foo visibility:public modality:OPEN <> ($this:foo.BaseImpl, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.BaseImpl + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.BaseImpl' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Base: " + CALL 'public final fun (): kotlin.String declared in foo.BaseImpl' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.foo' type=foo.BaseImpl origin=null + CONST String type=kotlin.String value=":" + GET_VAR 'x: kotlin.String declared in foo.BaseImpl.foo' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + $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 foo.Base + $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 foo.Base + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Base2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base2 + FUN name:bar visibility:public modality:ABSTRACT <> ($this:foo.Base2, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:foo.Base2 + VALUE_PARAMETER name:x index:0 type:kotlin.String + 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 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:Base2Impl modality:FINAL visibility:public superTypes:[foo.Base2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base2Impl + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:foo.Base2Impl [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base2Impl modality:FINAL visibility:public superTypes:[foo.Base2]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in foo.Base2Impl.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.Base2Impl) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.Base2Impl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.Base2Impl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.Base2Impl declared in foo.Base2Impl.' type=foo.Base2Impl origin=null + FUN name:bar visibility:public modality:OPEN <> ($this:foo.Base2Impl, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Base2Impl + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Base2Impl' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Base2: " + CALL 'public final fun (): kotlin.String declared in foo.Base2Impl' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': foo.Base2Impl declared in foo.Base2Impl.bar' type=foo.Base2Impl origin=null + CONST String type=kotlin.String value=":" + GET_VAR 'x: kotlin.String declared in foo.Base2Impl.bar' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + $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 foo.Base2 + $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 foo.Base2 + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:global visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.String declared in foo.' type=kotlin.String origin=null + CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.DerivedBase + CONSTRUCTOR visibility:public <> () returnType:foo.DerivedBase [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any]' + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":DerivedBase" + 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 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:newBase visibility:public modality:FINAL <> () returnType:foo.Base + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":newBase" + RETURN type=kotlin.Nothing from='public final fun newBase (): foo.Base declared in foo' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) declared in foo.BaseImpl' type=foo.BaseImpl origin=null + s: CONST String type=kotlin.String value="test" + FUN name:newBase2 visibility:public modality:FINAL <> () returnType:foo.Base2 + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":newBase2" + RETURN type=kotlin.Nothing from='public final fun newBase2 (): foo.Base2 declared in foo' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) declared in foo.Base2Impl' type=foo.Base2Impl origin=null + s: CONST String type=kotlin.String value="test" + CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base; foo.Base2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived + CONSTRUCTOR visibility:public <> () returnType:foo.Derived [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base; foo.Base2]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived declared in foo.Derived.foo' type=foo.Derived origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:foo.Derived, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Derived + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Derived' + CALL 'public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final]' type=foo.Base2 origin=null + receiver: GET_VAR ': foo.Derived declared in foo.Derived.bar' type=foo.Derived origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived.bar' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase2 (): foo.Base2 declared in foo' type=foo.Base2 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.DerivedBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + $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 foo.DerivedBase + public open fun hashCode (): kotlin.Int declared in foo.Base + public open fun hashCode (): kotlin.Int declared in foo.Base2 + $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 foo.DerivedBase + public open fun toString (): kotlin.String declared in foo.Base + public open fun toString (): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase; foo.Base2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived1 + CONSTRUCTOR visibility:public <> () returnType:foo.Derived1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase; foo.Base2]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived1, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived1 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived1' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived1 declared in foo.Derived1.foo' type=foo.Derived1 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived1.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:foo.Derived1, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Derived1 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Derived1' + CALL 'public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final]' type=foo.Base2 origin=null + receiver: GET_VAR ': foo.Derived1 declared in foo.Derived1.bar' type=foo.Derived1 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived1.bar' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase2 (): foo.Base2 declared in foo' type=foo.Base2 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.DerivedBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + $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 foo.Base + public open fun hashCode (): kotlin.Int declared in foo.DerivedBase + public open fun hashCode (): kotlin.Int declared in foo.Base2 + $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 foo.Base + public open fun toString (): kotlin.String declared in foo.DerivedBase + public open fun toString (): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[foo.Base; foo.Base2; foo.DerivedBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived2 + CONSTRUCTOR visibility:public <> () returnType:foo.Derived2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[foo.Base; foo.Base2; foo.DerivedBase]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived2, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived2 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived2' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived2 declared in foo.Derived2.foo' type=foo.Derived2 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived2.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:foo.Derived2, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Derived2 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Derived2' + CALL 'public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final]' type=foo.Base2 origin=null + receiver: GET_VAR ': foo.Derived2 declared in foo.Derived2.bar' type=foo.Derived2 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived2.bar' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase2 (): foo.Base2 declared in foo' type=foo.Base2 origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=EQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=GET_PROPERTY + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.DerivedBase + $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 foo.Base + public open fun hashCode (): kotlin.Int declared in foo.Base2 + public open fun hashCode (): kotlin.Int declared in foo.DerivedBase + $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 foo.Base + public open fun toString (): kotlin.String declared in foo.Base2 + public open fun toString (): kotlin.String declared in foo.DerivedBase + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:d type:foo.Derived [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived' type=foo.Derived origin=null + VAR name:d1 type:foo.Derived1 [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived1' type=foo.Derived1 origin=null + VAR name:d2 type:foo.Derived2 [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived2' type=foo.Derived2 origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in foo' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.fir.kt.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.fir.kt.txt new file mode 100644 index 00000000000..2e2475248a0 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.fir.kt.txt @@ -0,0 +1,150 @@ +package foo + +interface Base { + abstract fun foo(x: String): String + +} + +class BaseImpl : Base { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: String + field = s + get + + override fun foo(x: String): String { + return "Base: " + .() + ":" + x + } + +} + +interface Base2 { + abstract fun bar(x: String): String + +} + +class Base2Impl : Base2 { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: String + field = s + get + + override fun bar(x: String): String { + return "Base2: " + .() + ":" + x + } + +} + +var global: String + field = "" + get + set + +open class DerivedBase { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + init { + ( = ().plus(other = ":DerivedBase")) + } + +} + +fun newBase(): Base { + ( = ().plus(other = ":newBase")) + return BaseImpl(s = "test") +} + +fun newBase2(): Base2 { + ( = ().plus(other = ":newBase2")) + return Base2Impl(s = "test") +} + +class Derived : DerivedBase, Base, Base2 { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun bar(x: String): String { + return .#$$delegate_1.bar(x = x) + } + + private /* final field */ val $$delegate_1: Base2 = newBase2() + init { + ( = ().plus(other = ":Derived")) + } + +} + +class Derived1 : Base, DerivedBase, Base2 { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun bar(x: String): String { + return .#$$delegate_1.bar(x = x) + } + + private /* final field */ val $$delegate_1: Base2 = newBase2() + init { + ( = ().plus(other = ":Derived")) + } + +} + +class Derived2 : Base, Base2, DerivedBase { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun bar(x: String): String { + return .#$$delegate_1.bar(x = x) + } + + private /* final field */ val $$delegate_1: Base2 = newBase2() + init { + ( = ().plus(other = ":Derived")) + } + +} + +fun box(): String { + var d: Derived = Derived() + var d1: Derived1 = Derived1() + var d2: Derived2 = Derived2() + return "OK" +} + diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.ir.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.ir.txt new file mode 100644 index 00000000000..afde5368773 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.ir.txt @@ -0,0 +1,376 @@ +FILE fqName:foo fileName:/delegationEvaluationOrder2.kt + CLASS INTERFACE name:Base modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base + FUN name:foo visibility:public modality:ABSTRACT <> ($this:foo.Base, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:foo.Base + VALUE_PARAMETER name:x index:0 type:kotlin.String + 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 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:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.BaseImpl + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:foo.BaseImpl [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:BaseImpl modality:FINAL visibility:public superTypes:[foo.Base]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in foo.BaseImpl.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.BaseImpl) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.BaseImpl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.BaseImpl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.' type=foo.BaseImpl origin=null + FUN name:foo visibility:public modality:OPEN <> ($this:foo.BaseImpl, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.BaseImpl + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.BaseImpl' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Base: " + CALL 'public final fun (): kotlin.String declared in foo.BaseImpl' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': foo.BaseImpl declared in foo.BaseImpl.foo' type=foo.BaseImpl origin=null + CONST String type=kotlin.String value=":" + GET_VAR 'x: kotlin.String declared in foo.BaseImpl.foo' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + $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 foo.Base + $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 foo.Base + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:Base2 modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base2 + FUN name:bar visibility:public modality:ABSTRACT <> ($this:foo.Base2, x:kotlin.String) returnType:kotlin.String + $this: VALUE_PARAMETER name: type:foo.Base2 + VALUE_PARAMETER name:x index:0 type:kotlin.String + 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 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:Base2Impl modality:FINAL visibility:public superTypes:[foo.Base2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Base2Impl + CONSTRUCTOR visibility:public <> (s:kotlin.String) returnType:foo.Base2Impl [primary] + VALUE_PARAMETER name:s index:0 type:kotlin.String + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Base2Impl modality:FINAL visibility:public superTypes:[foo.Base2]' + PROPERTY name:s visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final] + EXPRESSION_BODY + GET_VAR 's: kotlin.String declared in foo.Base2Impl.' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:foo.Base2Impl) returnType:kotlin.String + correspondingProperty: PROPERTY name:s visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:foo.Base2Impl + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo.Base2Impl' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.String origin=null + receiver: GET_VAR ': foo.Base2Impl declared in foo.Base2Impl.' type=foo.Base2Impl origin=null + FUN name:bar visibility:public modality:OPEN <> ($this:foo.Base2Impl, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Base2Impl + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Base2Impl' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value="Base2: " + CALL 'public final fun (): kotlin.String declared in foo.Base2Impl' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR ': foo.Base2Impl declared in foo.Base2Impl.bar' type=foo.Base2Impl origin=null + CONST String type=kotlin.String value=":" + GET_VAR 'x: kotlin.String declared in foo.Base2Impl.bar' type=kotlin.String origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + $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 foo.Base2 + $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 foo.Base2 + $this: VALUE_PARAMETER name: type:kotlin.Any + PROPERTY name:global visibility:public modality:FINAL [var] + FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static] + EXPRESSION_BODY + CONST String type=kotlin.String value="" + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.String declared in foo' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.String origin=null + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> (:kotlin.String) returnType:kotlin.Unit + correspondingProperty: PROPERTY name:global visibility:public modality:FINAL [var] + VALUE_PARAMETER name: index:0 type:kotlin.String + BLOCK_BODY + SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:global type:kotlin.String visibility:private [static]' type=kotlin.Unit origin=null + value: GET_VAR ': kotlin.String declared in foo.' type=kotlin.String origin=null + CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.DerivedBase + CONSTRUCTOR visibility:public <> () returnType:foo.DerivedBase [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedBase modality:OPEN visibility:public superTypes:[kotlin.Any]' + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":DerivedBase" + 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 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:newBase visibility:public modality:FINAL <> () returnType:foo.Base + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":newBase" + RETURN type=kotlin.Nothing from='public final fun newBase (): foo.Base declared in foo' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) declared in foo.BaseImpl' type=foo.BaseImpl origin=null + s: CONST String type=kotlin.String value="test" + FUN name:newBase2 visibility:public modality:FINAL <> () returnType:foo.Base2 + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":newBase2" + RETURN type=kotlin.Nothing from='public final fun newBase2 (): foo.Base2 declared in foo' + CONSTRUCTOR_CALL 'public constructor (s: kotlin.String) declared in foo.Base2Impl' type=foo.Base2Impl origin=null + s: CONST String type=kotlin.String value="test" + CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base; foo.Base2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived + CONSTRUCTOR visibility:public <> () returnType:foo.Derived [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[foo.DerivedBase; foo.Base; foo.Base2]' + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived declared in foo.Derived.foo' type=foo.Derived origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase2 (): foo.Base2 declared in foo' type=foo.Base2 origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:foo.Derived, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Derived + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Derived' + CALL 'public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final]' type=foo.Base2 origin=null + receiver: GET_VAR ': foo.Derived declared in foo.Derived.bar' type=foo.Derived origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived.bar' type=kotlin.String origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.DerivedBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + $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 foo.DerivedBase + public open fun hashCode (): kotlin.Int declared in foo.Base + public open fun hashCode (): kotlin.Int declared in foo.Base2 + $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 foo.DerivedBase + public open fun toString (): kotlin.String declared in foo.Base + public open fun toString (): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase; foo.Base2] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived1 + CONSTRUCTOR visibility:public <> () returnType:foo.Derived1 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[foo.Base; foo.DerivedBase; foo.Base2]' + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived1, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived1 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived1' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived1 declared in foo.Derived1.foo' type=foo.Derived1 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived1.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase2 (): foo.Base2 declared in foo' type=foo.Base2 origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:foo.Derived1, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Derived1 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Derived1' + CALL 'public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final]' type=foo.Base2 origin=null + receiver: GET_VAR ': foo.Derived1 declared in foo.Derived1.bar' type=foo.Derived1 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived1.bar' type=kotlin.String origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.DerivedBase + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + $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 foo.Base + public open fun hashCode (): kotlin.Int declared in foo.DerivedBase + public open fun hashCode (): kotlin.Int declared in foo.Base2 + $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 foo.Base + public open fun toString (): kotlin.String declared in foo.DerivedBase + public open fun toString (): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[foo.Base; foo.Base2; foo.DerivedBase] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:foo.Derived2 + CONSTRUCTOR visibility:public <> () returnType:foo.Derived2 [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () declared in foo.DerivedBase' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived2 modality:FINAL visibility:public superTypes:[foo.Base; foo.Base2; foo.DerivedBase]' + FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase (): foo.Base declared in foo' type=foo.Base origin=null + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:foo.Derived2, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base + $this: VALUE_PARAMETER name: type:foo.Derived2 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (x: kotlin.String): kotlin.String declared in foo.Derived2' + CALL 'public abstract fun foo (x: kotlin.String): kotlin.String declared in foo.Base' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:foo.Base visibility:private [final]' type=foo.Base origin=null + receiver: GET_VAR ': foo.Derived2 declared in foo.Derived2.foo' type=foo.Derived2 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived2.foo' type=kotlin.String origin=null + FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final] + EXPRESSION_BODY + CALL 'public final fun newBase2 (): foo.Base2 declared in foo' type=foo.Base2 origin=null + FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:foo.Derived2, x:kotlin.String) returnType:kotlin.String + overridden: + public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2 + $this: VALUE_PARAMETER name: type:foo.Derived2 + VALUE_PARAMETER name:x index:0 type:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun bar (x: kotlin.String): kotlin.String declared in foo.Derived2' + CALL 'public abstract fun bar (x: kotlin.String): kotlin.String declared in foo.Base2' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:foo.Base2 visibility:private [final]' type=foo.Base2 origin=null + receiver: GET_VAR ': foo.Derived2 declared in foo.Derived2.bar' type=foo.Derived2 origin=null + x: GET_VAR 'x: kotlin.String declared in foo.Derived2.bar' type=kotlin.String origin=null + ANONYMOUS_INITIALIZER isStatic=false + BLOCK_BODY + BLOCK type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun (: kotlin.String): kotlin.Unit declared in foo' type=kotlin.Unit origin=PLUSEQ + : CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=PLUSEQ + $this: CALL 'public final fun (): kotlin.String declared in foo' type=kotlin.String origin=PLUSEQ + other: CONST String type=kotlin.String value=":Derived" + 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 declared in foo.Base + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.Base2 + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in foo.DerivedBase + $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 foo.Base + public open fun hashCode (): kotlin.Int declared in foo.Base2 + public open fun hashCode (): kotlin.Int declared in foo.DerivedBase + $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 foo.Base + public open fun toString (): kotlin.String declared in foo.Base2 + public open fun toString (): kotlin.String declared in foo.DerivedBase + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:d type:foo.Derived [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived' type=foo.Derived origin=null + VAR name:d1 type:foo.Derived1 [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived1' type=foo.Derived1 origin=null + VAR name:d2 type:foo.Derived2 [var] + CONSTRUCTOR_CALL 'public constructor () declared in foo.Derived2' type=foo.Derived2 origin=null + RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in foo' + CONST String type=kotlin.String value="OK" diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt new file mode 100644 index 00000000000..d0697bfec0b --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt @@ -0,0 +1,61 @@ +package foo + +interface Base { + abstract fun foo(x: String): String +} + +class BaseImpl(val s: String) : Base { + override fun foo(x: String): String = "Base: ${s}:${x}" +} + +interface Base2 { + abstract fun bar(x: String): String +} + +class Base2Impl(val s: String) : Base2 { + override fun bar(x: String): String = "Base2: ${s}:${x}" +} + +var global = "" + +open class DerivedBase() { + init { + global += ":DerivedBase" + } +} + +fun newBase(): Base { + global += ":newBase" + return BaseImpl("test") +} + +fun newBase2(): Base2 { + global += ":newBase2" + return Base2Impl("test") +} + +class Derived() : DerivedBase(), Base by newBase(), Base2 by newBase2() { + init { + global += ":Derived" + } +} + +class Derived1() : Base by newBase(), DerivedBase(), Base2 by newBase2() { + init { + global += ":Derived" + } +} + +class Derived2() : Base by newBase(), Base2 by newBase2(), DerivedBase() { + init { + global += ":Derived" + } +} + +fun box(): String { + var d = Derived() + var d1 = Derived1() + var d2 = Derived2() + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt.txt new file mode 100644 index 00000000000..ed79dc75b06 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt.txt @@ -0,0 +1,161 @@ +package foo + +interface Base { + abstract fun foo(x: String): String + +} + +class BaseImpl : Base { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: String + field = s + get + + override fun foo(x: String): String { + return "Base: " + .() + ":" + x + } + +} + +interface Base2 { + abstract fun bar(x: String): String + +} + +class Base2Impl : Base2 { + constructor(s: String) /* primary */ { + super/*Any*/() + /* () */ + + } + + val s: String + field = s + get + + override fun bar(x: String): String { + return "Base2: " + .() + ":" + x + } + +} + +var global: String + field = "" + get + set + +open class DerivedBase { + constructor() /* primary */ { + super/*Any*/() + /* () */ + + } + + init { + { // BLOCK + ( = ().plus(other = ":DerivedBase")) + } + } + +} + +fun newBase(): Base { + { // BLOCK + ( = ().plus(other = ":newBase")) + } + return BaseImpl(s = "test") +} + +fun newBase2(): Base2 { + { // BLOCK + ( = ().plus(other = ":newBase2")) + } + return Base2Impl(s = "test") +} + +class Derived : DerivedBase, Base, Base2 { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_1: Base2 = newBase2() + override fun bar(x: String): String { + return .#$$delegate_1.bar(x = x) + } + + init { + { // BLOCK + ( = ().plus(other = ":Derived")) + } + } + +} + +class Derived1 : Base, DerivedBase, Base2 { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_1: Base2 = newBase2() + override fun bar(x: String): String { + return .#$$delegate_1.bar(x = x) + } + + init { + { // BLOCK + ( = ().plus(other = ":Derived")) + } + } + +} + +class Derived2 : Base, Base2, DerivedBase { + constructor() /* primary */ { + super/*DerivedBase*/() + /* () */ + + } + + private /* final field */ val $$delegate_0: Base = newBase() + override fun foo(x: String): String { + return .#$$delegate_0.foo(x = x) + } + + private /* final field */ val $$delegate_1: Base2 = newBase2() + override fun bar(x: String): String { + return .#$$delegate_1.bar(x = x) + } + + init { + { // BLOCK + ( = ().plus(other = ":Derived")) + } + } + +} + +fun box(): String { + var d: Derived = Derived() + var d1: Derived1 = Derived1() + var d2: Derived2 = Derived2() + return "OK" +} diff --git a/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.sig.kt.txt b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.sig.kt.txt new file mode 100644 index 00000000000..90243f54201 --- /dev/null +++ b/compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.sig.kt.txt @@ -0,0 +1,319 @@ +package foo + +// CHECK: +// Mangled name: foo{}global +// Public signature: foo/global|4288684431328455501[0] +// Public signature debug description: {}global +var global: String + // CHECK JVM_IR: + // Mangled name: foo#(){}kotlin.String + // Public signature: foo/global.|-6997244913903542523[0] + // Public signature debug description: (){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo#(){} + // Public signature: foo/global.|7627852862574367240[0] + // Public signature debug description: (){} + get + // CHECK: + // Mangled name: foo#(kotlin.String){} + // Public signature: foo/global.|5315586845372819266[0] + // Public signature debug description: (kotlin.String){} + set + +// CHECK: +// Mangled name: foo.Base2Impl +// Public signature: foo/Base2Impl|null[0] +class Base2Impl : Base2 { + // CHECK: + // Mangled name: foo.Base2Impl{}s + // Public signature: foo/Base2Impl.s|7217541905509134881[0] + // Public signature debug description: {}s + val s: String + // CHECK JVM_IR: + // Mangled name: foo.Base2Impl#(){}kotlin.String + // Public signature: foo/Base2Impl.s.|4142379646177092803[0] + // Public signature debug description: (){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Base2Impl#(){} + // Public signature: foo/Base2Impl.s.|-1662172381559511151[0] + // Public signature debug description: (){} + get + + // CHECK: + // Mangled name: foo.Base2Impl#(kotlin.String){} + // Public signature: foo/Base2Impl.|1280618353163213788[0] + // Public signature debug description: (kotlin.String){} + constructor(s: String) /* primary */ + + // CHECK JVM_IR: + // Mangled name: foo.Base2Impl#bar(kotlin.String){}kotlin.String + // Public signature: foo/Base2Impl.bar|2000415168157940991[0] + // Public signature debug description: bar(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Base2Impl#bar(kotlin.String){} + // Public signature: foo/Base2Impl.bar|5132770888056479978[0] + // Public signature debug description: bar(kotlin.String){} + override fun bar(x: String): String + +} + +// CHECK: +// Mangled name: foo.BaseImpl +// Public signature: foo/BaseImpl|null[0] +class BaseImpl : Base { + // CHECK: + // Mangled name: foo.BaseImpl{}s + // Public signature: foo/BaseImpl.s|7217541905509134881[0] + // Public signature debug description: {}s + val s: String + // CHECK JVM_IR: + // Mangled name: foo.BaseImpl#(){}kotlin.String + // Public signature: foo/BaseImpl.s.|4142379646177092803[0] + // Public signature debug description: (){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.BaseImpl#(){} + // Public signature: foo/BaseImpl.s.|-1662172381559511151[0] + // Public signature debug description: (){} + get + + // CHECK: + // Mangled name: foo.BaseImpl#(kotlin.String){} + // Public signature: foo/BaseImpl.|1280618353163213788[0] + // Public signature debug description: (kotlin.String){} + constructor(s: String) /* primary */ + + // CHECK JVM_IR: + // Mangled name: foo.BaseImpl#foo(kotlin.String){}kotlin.String + // Public signature: foo/BaseImpl.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.BaseImpl#foo(kotlin.String){} + // Public signature: foo/BaseImpl.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.Derived +// Public signature: foo/Derived|null[0] +class Derived : DerivedBase, Base, Base2 { + // CHECK: + // Mangled name: foo.Derived#(){} + // Public signature: foo/Derived.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + // CHECK JVM_IR: + // Mangled name: foo.Derived.$$delegate_0 + // Public signature: foo/Derived.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived.$$delegate_0 + // Public signature: foo/Derived.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_0: Base + // CHECK JVM_IR: + // Mangled name: foo.Derived.$$delegate_1 + // Public signature: foo/Derived.$$delegate_1|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived.$$delegate_1 + // Public signature: foo/Derived.$$delegate_1|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_1: Base2 + // CHECK JVM_IR: + // Mangled name: foo.Derived#bar(kotlin.String){}kotlin.String + // Public signature: foo/Derived.bar|2000415168157940991[0] + // Public signature debug description: bar(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived#bar(kotlin.String){} + // Public signature: foo/Derived.bar|5132770888056479978[0] + // Public signature debug description: bar(kotlin.String){} + override fun bar(x: String): String + + // CHECK JVM_IR: + // Mangled name: foo.Derived#foo(kotlin.String){}kotlin.String + // Public signature: foo/Derived.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived#foo(kotlin.String){} + // Public signature: foo/Derived.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.Derived1 +// Public signature: foo/Derived1|null[0] +class Derived1 : DerivedBase, Base, Base2 { + // CHECK: + // Mangled name: foo.Derived1#(){} + // Public signature: foo/Derived1.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + // CHECK JVM_IR: + // Mangled name: foo.Derived1.$$delegate_0 + // Public signature: foo/Derived1.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived1.$$delegate_0 + // Public signature: foo/Derived1.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_0: Base + // CHECK JVM_IR: + // Mangled name: foo.Derived1.$$delegate_1 + // Public signature: foo/Derived1.$$delegate_1|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived1.$$delegate_1 + // Public signature: foo/Derived1.$$delegate_1|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_1: Base2 + // CHECK JVM_IR: + // Mangled name: foo.Derived1#bar(kotlin.String){}kotlin.String + // Public signature: foo/Derived1.bar|2000415168157940991[0] + // Public signature debug description: bar(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived1#bar(kotlin.String){} + // Public signature: foo/Derived1.bar|5132770888056479978[0] + // Public signature debug description: bar(kotlin.String){} + override fun bar(x: String): String + + // CHECK JVM_IR: + // Mangled name: foo.Derived1#foo(kotlin.String){}kotlin.String + // Public signature: foo/Derived1.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived1#foo(kotlin.String){} + // Public signature: foo/Derived1.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.Derived2 +// Public signature: foo/Derived2|null[0] +class Derived2 : DerivedBase, Base, Base2 { + // CHECK: + // Mangled name: foo.Derived2#(){} + // Public signature: foo/Derived2.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + // CHECK JVM_IR: + // Mangled name: foo.Derived2.$$delegate_0 + // Public signature: foo/Derived2.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived2.$$delegate_0 + // Public signature: foo/Derived2.$$delegate_0|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_0: Base + // CHECK JVM_IR: + // Mangled name: foo.Derived2.$$delegate_1 + // Public signature: foo/Derived2.$$delegate_1|-7286425919675154353[0] + // Public signature debug description: + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived2.$$delegate_1 + // Public signature: foo/Derived2.$$delegate_1|-7286425919675154353[0] + // Public signature debug description: + private /* final field */ val $$delegate_1: Base2 + // CHECK JVM_IR: + // Mangled name: foo.Derived2#bar(kotlin.String){}kotlin.String + // Public signature: foo/Derived2.bar|2000415168157940991[0] + // Public signature debug description: bar(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived2#bar(kotlin.String){} + // Public signature: foo/Derived2.bar|5132770888056479978[0] + // Public signature debug description: bar(kotlin.String){} + override fun bar(x: String): String + + // CHECK JVM_IR: + // Mangled name: foo.Derived2#foo(kotlin.String){}kotlin.String + // Public signature: foo/Derived2.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Derived2#foo(kotlin.String){} + // Public signature: foo/Derived2.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + override fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.DerivedBase +// Public signature: foo/DerivedBase|null[0] +open class DerivedBase { + // CHECK: + // Mangled name: foo.DerivedBase#(){} + // Public signature: foo/DerivedBase.|-5645683436151566731[0] + // Public signature debug description: (){} + constructor() /* primary */ + +} + +// CHECK: +// Mangled name: foo.Base +// Public signature: foo/Base|null[0] +interface Base { + + // CHECK JVM_IR: + // Mangled name: foo.Base#foo(kotlin.String){}kotlin.String + // Public signature: foo/Base.foo|-5534735991146511619[0] + // Public signature debug description: foo(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Base#foo(kotlin.String){} + // Public signature: foo/Base.foo|1351044947738582195[0] + // Public signature debug description: foo(kotlin.String){} + abstract fun foo(x: String): String + +} + +// CHECK: +// Mangled name: foo.Base2 +// Public signature: foo/Base2|null[0] +interface Base2 { + + // CHECK JVM_IR: + // Mangled name: foo.Base2#bar(kotlin.String){}kotlin.String + // Public signature: foo/Base2.bar|2000415168157940991[0] + // Public signature debug description: bar(kotlin.String){}kotlin.String + // CHECK JS_IR NATIVE: + // Mangled name: foo.Base2#bar(kotlin.String){} + // Public signature: foo/Base2.bar|5132770888056479978[0] + // Public signature debug description: bar(kotlin.String){} + abstract fun bar(x: String): String + +} + +// CHECK JVM_IR: +// Mangled name: foo#box(){}kotlin.String +// Public signature: foo/box|-9347091776561469[0] +// Public signature debug description: box(){}kotlin.String +// CHECK JS_IR NATIVE: +// Mangled name: foo#box(){} +// Public signature: foo/box|2173511048851971368[0] +// Public signature debug description: box(){} +fun box(): String + +// CHECK JVM_IR: +// Mangled name: foo#newBase(){}foo.Base +// Public signature: foo/newBase|4074800280318487147[0] +// Public signature debug description: newBase(){}foo.Base +// CHECK JS_IR NATIVE: +// Mangled name: foo#newBase(){} +// Public signature: foo/newBase|-6094796879594303932[0] +// Public signature debug description: newBase(){} +fun newBase(): Base + +// CHECK JVM_IR: +// Mangled name: foo#newBase2(){}foo.Base2 +// Public signature: foo/newBase2|2155458060891401186[0] +// Public signature debug description: newBase2(){}foo.Base2 +// CHECK JS_IR NATIVE: +// Mangled name: foo#newBase2(){} +// Public signature: foo/newBase2|-3649949204944094884[0] +// Public signature debug description: newBase2(){} +fun newBase2(): Base2 + diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 81d5ace4c0a..de711455e51 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -972,6 +972,28 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + public class Delegate { + @Test + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @Test + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java index 5904b6122d1..6e6e04c25d4 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java @@ -782,6 +782,29 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase { } } + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Delegate extends AbstractKlibIrTextTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JS_IR, testDataFilePath, "// IGNORE_BACKEND_KLIB: "); + } + + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java index 4ee9cebd959..1ce52eed389 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java @@ -894,6 +894,28 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + public class Delegate { + @Test + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @Test + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java index 36046491579..7a940efb8d1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java @@ -894,6 +894,28 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest { } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + public class Delegate { + @Test + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @Test + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java index 14b1fe25e30..199503a005e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java @@ -894,6 +894,28 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest { } } + @Nested + @TestMetadata("compiler/testData/ir/irText/declarations/delegate") + @TestDataPath("$PROJECT_ROOT") + public class Delegate { + @Test + public void testAllFilesPresentInDelegate() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/declarations/delegate"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("delegationEvaluationOrder1.kt") + public void testDelegationEvaluationOrder1() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder1.kt"); + } + + @Test + @TestMetadata("delegationEvaluationOrder2.kt") + public void testDelegationEvaluationOrder2() throws Exception { + runTest("compiler/testData/ir/irText/declarations/delegate/delegationEvaluationOrder2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/ir/irText/declarations/jvmRecord") @TestDataPath("$PROJECT_ROOT")