From e327b174a22ff4f50023d4267f9ae43bd313601f Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Thu, 16 Jan 2020 15:30:13 +0100 Subject: [PATCH] IR: Use name \$\$delegate_n for the field for interface delegation. Without this change, these fields could have names such as `$SuperClass$delegate` for something like `object SuperClass by I { }`. --- .../psi2ir/generators/ClassGenerator.kt | 8 +++-- .../ir/descriptors/IrDelegateDescriptor.kt | 12 ++------ .../codegen/box/delegation/delegationToVal.kt | 1 + .../delegatedGenericImplementation.txt | 20 ++++++------- .../classes/delegatedImplementation.txt | 30 +++++++++---------- ...atedImplementationWithExplicitOverride.txt | 4 +-- ...plicitNotNullOnDelegatedImplementation.txt | 20 ++++++------- .../ir/irText/declarations/kt35550.txt | 4 +-- .../parameters/delegatedMembers.txt | 8 ++--- 9 files changed, 52 insertions(+), 55 deletions(-) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index a1edeabfe8a..b031d0f8996 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -155,16 +155,18 @@ class ClassGenerator( private fun generateMembersDeclaredInSupertypeList(irClass: IrClass, ktClassOrObject: KtClassOrObject) { val ktSuperTypeList = ktClassOrObject.getSuperTypeList() ?: return + var delegateNumber = 0 for (ktEntry in ktSuperTypeList.entries) { if (ktEntry is KtDelegatedSuperTypeEntry) { - generateDelegatedImplementationMembers(irClass, ktEntry) + generateDelegatedImplementationMembers(irClass, ktEntry, delegateNumber++) } } } private fun generateDelegatedImplementationMembers( irClass: IrClass, - ktEntry: KtDelegatedSuperTypeEntry + ktEntry: KtDelegatedSuperTypeEntry, + delegateNumber: Int ) { val ktDelegateExpression = ktEntry.delegateExpression!! val delegateType = getTypeInferredByFrontendOrFail(ktDelegateExpression) @@ -174,7 +176,7 @@ class ClassGenerator( val superClass = superTypeConstructorDescriptor as? ClassDescriptor ?: throw AssertionError("Unexpected supertype constructor for delegation: $superTypeConstructorDescriptor") - val delegateDescriptor = IrImplementingDelegateDescriptorImpl(irClass.descriptor, delegateType, superType) + val delegateDescriptor = IrImplementingDelegateDescriptorImpl(irClass.descriptor, delegateType, superType, delegateNumber) val irDelegateField = context.symbolTable.declareField( ktDelegateExpression.startOffsetSkippingComments, ktDelegateExpression.endOffset, IrDeclarationOrigin.DELEGATE, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt index 84b90b14efa..306fa5ebd21 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/descriptors/IrDelegateDescriptor.kt @@ -104,11 +104,12 @@ class IrPropertyDelegateDescriptorImpl( class IrImplementingDelegateDescriptorImpl( containingDeclaration: ClassDescriptor, delegateType: KotlinType, - override val correspondingSuperType: KotlinType + override val correspondingSuperType: KotlinType, + number: Int ) : IrDelegateDescriptorBase( containingDeclaration, - getDelegateName(containingDeclaration, correspondingSuperType), + Name.identifier("\$\$delegate_$number"), delegateType ), IrImplementingDelegateDescriptor @@ -116,13 +117,6 @@ class IrImplementingDelegateDescriptorImpl( internal fun getDelegateName(name: Name): Name = Name.identifier(name.asString() + "\$delegate") -internal fun getDelegateName(classDescriptor: ClassDescriptor, superType: KotlinType): Name = - Name.identifier( - classDescriptor.name.asString() + "\$" + - (superType.constructor.declarationDescriptor?.name ?: "\$") + - "\$delegate" - ) - class IrLocalDelegatedPropertyDelegateDescriptorImpl( override val correspondingLocalProperty: VariableDescriptorWithAccessors, delegateType: KotlinType, diff --git a/compiler/testData/codegen/box/delegation/delegationToVal.kt b/compiler/testData/codegen/box/delegation/delegationToVal.kt index 2a8e0f397ca..e8b30ebfb54 100644 --- a/compiler/testData/codegen/box/delegation/delegationToVal.kt +++ b/compiler/testData/codegen/box/delegation/delegationToVal.kt @@ -1,4 +1,5 @@ // IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_BACKEND: JVM_IR // TARGET_BACKEND: JVM // WITH_RUNTIME diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt index bed371e13c6..e41abf3def2 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.txt @@ -46,7 +46,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase.Test1>]' - FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final] EXPRESSION_BODY GET_VAR 'i: .IBase.Test1> declared in .Test1.' type=.IBase.Test1> origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN ($this:.Test1.Test1>, a:E of .Test1, b:B of .Test1.foo) returnType:kotlin.Unit @@ -59,7 +59,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null : B of .Test1.foo - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.foo' type=.Test1.Test1> origin=null a: GET_VAR 'a: E of .Test1 declared in .Test1.foo' type=E of .Test1 origin=null b: GET_VAR 'b: B of .Test1.foo declared in .Test1.foo' type=B of .Test1.foo origin=null @@ -75,7 +75,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test1, C of .Test1.>? declared in .Test1' CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test1, C of .Test1.>? origin=null : C of .Test1. - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null $receiver: GET_VAR ': C of .Test1. declared in .Test1.' type=C of .Test1. origin=null PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] @@ -90,7 +90,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt RETURN type=kotlin.Nothing from='public open fun (): D of .Test1.? declared in .Test1' CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test1.? origin=null : D of .Test1. - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null $receiver: GET_VAR ': kotlin.collections.List.Test1.> declared in .Test1.' type=kotlin.collections.List.Test1.> origin=null FUN DELEGATED_MEMBER name: visibility:public modality:OPEN ($this:.Test1.Test1>, $receiver:kotlin.collections.List.Test1.>, :D of .Test1.?) returnType:kotlin.Unit @@ -104,7 +104,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null : D of .Test1. - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test1> visibility:private [final]' type=.IBase.Test1> origin=null receiver: GET_VAR ': .Test1.Test1> declared in .Test1.' type=.Test1.Test1> origin=null $receiver: GET_VAR ': kotlin.collections.List.Test1.> declared in .Test1.' type=kotlin.collections.List.Test1.> origin=null : GET_VAR ': D of .Test1.? declared in .Test1.' type=D of .Test1.? origin=null @@ -147,7 +147,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' type=kotlin.Unit origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null value: GET_VAR ': .IBase declared in .Test2.' type=.IBase origin=null - FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:private [final] EXPRESSION_BODY GET_VAR 'j: .IBase declared in .Test2.' type=.IBase origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN ($this:.Test2, a:kotlin.String, b:B of .Test2.foo) returnType:kotlin.Unit @@ -160,7 +160,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY CALL 'public abstract fun foo (a: A of .IBase, b: B of .IBase.foo): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null : B of .Test2.foo - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:private [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null a: GET_VAR 'a: kotlin.String declared in .Test2.foo' type=kotlin.String origin=null b: GET_VAR 'b: B of .Test2.foo declared in .Test2.foo' type=B of .Test2.foo origin=null @@ -176,7 +176,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Map.Test2.>? declared in .Test2' CALL 'public abstract fun (): kotlin.collections.Map.IBase, C of .IBase.>? declared in .IBase' type=kotlin.collections.Map.Test2.>? origin=null : C of .Test2. - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:private [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': C of .Test2. declared in .Test2.' type=C of .Test2. origin=null PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [var] @@ -191,7 +191,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt RETURN type=kotlin.Nothing from='public open fun (): D of .Test2.? declared in .Test2' CALL 'public abstract fun (): D of .IBase.? declared in .IBase' type=D of .Test2.? origin=null : D of .Test2. - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:private [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.collections.List.Test2.> declared in .Test2.' type=kotlin.collections.List.Test2.> origin=null FUN DELEGATED_MEMBER name: visibility:public modality:OPEN ($this:.Test2, $receiver:kotlin.collections.List.Test2.>, :D of .Test2.?) returnType:kotlin.Unit @@ -205,7 +205,7 @@ FILE fqName: fileName:/delegatedGenericImplementation.kt BLOCK_BODY CALL 'public abstract fun (: D of .IBase.?): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null : D of .Test2. - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.IBase visibility:private [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase visibility:private [final]' type=.IBase origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.collections.List.Test2.> declared in .Test2.' type=kotlin.collections.List.Test2.> origin=null : GET_VAR ': D of .Test2.? declared in .Test2.' type=D of .Test2.? origin=null diff --git a/compiler/testData/ir/irText/classes/delegatedImplementation.txt b/compiler/testData/ir/irText/classes/delegatedImplementation.txt index 4b1b3f5791e..135011f6e0f 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementation.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementation.txt @@ -200,7 +200,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public superTypes:[.IBase]' - FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final] EXPRESSION_BODY GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[.IBase]' type=.BaseImpl FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:.Test1) returnType:kotlin.Int @@ -210,7 +210,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in .Test1' CALL 'public open fun bar (): kotlin.Int declared in .BaseImpl' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test1 declared in .Test1.bar' type=.Test1 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test1, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit overridden: @@ -220,7 +220,7 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name:s index:1 type:kotlin.String BLOCK_BODY CALL 'public open fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test1 declared in .Test1.foo' type=.Test1 origin=null x: GET_VAR 'x: kotlin.Int declared in .Test1.foo' type=kotlin.Int origin=null s: GET_VAR 's: kotlin.String declared in .Test1.foo' type=kotlin.String origin=null @@ -231,7 +231,7 @@ FILE fqName: fileName:/delegatedImplementation.kt $receiver: VALUE_PARAMETER name: type:kotlin.String BLOCK_BODY CALL 'public open fun qux (): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test1$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test1 declared in .Test1.qux' type=.Test1 origin=null $receiver: GET_VAR ': kotlin.String declared in .Test1.qux' 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] @@ -253,7 +253,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public superTypes:[.IBase; .IOther]' - FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final] EXPRESSION_BODY GET_OBJECT 'CLASS OBJECT name:BaseImpl modality:FINAL visibility:public superTypes:[.IBase]' type=.BaseImpl FUN DELEGATED_MEMBER name:bar visibility:public modality:OPEN <> ($this:.Test2) returnType:kotlin.Int @@ -263,7 +263,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun bar (): kotlin.Int declared in .Test2' CALL 'public open fun bar (): kotlin.Int declared in .BaseImpl' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test2 declared in .Test2.bar' type=.Test2 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.Test2, x:kotlin.Int, s:kotlin.String) returnType:kotlin.Unit overridden: @@ -273,7 +273,7 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name:s index:1 type:kotlin.String BLOCK_BODY CALL 'public open fun foo (x: kotlin.Int, s: kotlin.String): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test2 declared in .Test2.foo' type=.Test2 origin=null x: GET_VAR 'x: kotlin.Int declared in .Test2.foo' type=kotlin.Int origin=null s: GET_VAR 's: kotlin.String declared in .Test2.foo' type=kotlin.String origin=null @@ -284,10 +284,10 @@ FILE fqName: fileName:/delegatedImplementation.kt $receiver: VALUE_PARAMETER name: type:kotlin.String BLOCK_BODY CALL 'public open fun qux (): kotlin.Unit declared in .BaseImpl' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IBase$delegate type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.BaseImpl visibility:private [final]' type=.BaseImpl origin=null receiver: GET_VAR ': .Test2 declared in .Test2.qux' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.String declared in .Test2.qux' type=kotlin.String origin=null - FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final] + FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final] EXPRESSION_BODY CALL 'public final fun otherImpl (x0: kotlin.String, y0: kotlin.Int): .IOther declared in ' type=.IOther origin=null x0: CONST String type=kotlin.String value="" @@ -302,7 +302,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test2' CALL 'public abstract fun (): kotlin.Int declared in .IOther' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final]' type=.IOther origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final]' type=.IOther origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.Byte declared in .Test2.' type=kotlin.Byte origin=null PROPERTY DELEGATED_MEMBER name:x visibility:public modality:OPEN [val] @@ -314,7 +314,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.String declared in .Test2' CALL 'public abstract fun (): kotlin.String declared in .IOther' type=kotlin.String origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final]' type=.IOther origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final]' type=.IOther origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null PROPERTY DELEGATED_MEMBER name:z2 visibility:public modality:OPEN [var] FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, $receiver:kotlin.Byte) returnType:kotlin.Int @@ -326,7 +326,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test2' CALL 'public abstract fun (): kotlin.Int declared in .IOther' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final]' type=.IOther origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final]' type=.IOther origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.Byte declared in .Test2.' type=kotlin.Byte origin=null FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, $receiver:kotlin.Byte, :kotlin.Int) returnType:kotlin.Unit @@ -338,7 +338,7 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name: index:0 type:kotlin.Int BLOCK_BODY CALL 'public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final]' type=.IOther origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final]' type=.IOther origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null $receiver: GET_VAR ': kotlin.Byte declared in .Test2.' type=kotlin.Byte origin=null : GET_VAR ': kotlin.Int declared in .Test2.' type=kotlin.Int origin=null @@ -351,7 +351,7 @@ FILE fqName: fileName:/delegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test2' CALL 'public abstract fun (): kotlin.Int declared in .IOther' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final]' type=.IOther origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final]' type=.IOther origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null FUN DELEGATED_MEMBER name: visibility:public modality:OPEN <> ($this:.Test2, :kotlin.Int) returnType:kotlin.Unit correspondingProperty: PROPERTY DELEGATED_MEMBER name:y visibility:public modality:OPEN [var] @@ -361,7 +361,7 @@ FILE fqName: fileName:/delegatedImplementation.kt VALUE_PARAMETER name: index:0 type:kotlin.Int BLOCK_BODY CALL 'public abstract fun (: kotlin.Int): kotlin.Unit declared in .IOther' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test2$IOther$delegate type:.IOther visibility:private [final]' type=.IOther origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_1 type:.IOther visibility:private [final]' type=.IOther origin=null receiver: GET_VAR ': .Test2 declared in .Test2.' type=.Test2 origin=null : GET_VAR ': kotlin.Int declared in .Test2.' type=kotlin.Int origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt index d8d93e215f1..bef1b1f7c5c 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationWithExplicitOverride.txt @@ -53,7 +53,7 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.IFooBar]' - FIELD DELEGATE name:C$IFooBar$delegate type:.FooBarImpl visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.FooBarImpl visibility:private [final] EXPRESSION_BODY GET_OBJECT 'CLASS OBJECT name:FooBarImpl modality:FINAL visibility:public superTypes:[.IFooBar]' type=.FooBarImpl FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.Unit @@ -62,7 +62,7 @@ FILE fqName: fileName:/delegatedImplementationWithExplicitOverride.kt $this: VALUE_PARAMETER name: type:.C BLOCK_BODY CALL 'public open fun foo (): kotlin.Unit declared in .FooBarImpl' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:C$IFooBar$delegate type:.FooBarImpl visibility:private [final]' type=.FooBarImpl origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.FooBarImpl visibility:private [final]' type=.FooBarImpl origin=null receiver: GET_VAR ': .C declared in .C.foo' type=.C origin=null FUN name:bar visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.Unit overridden: diff --git a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt index f69e13973b2..8388f7164ec 100644 --- a/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt +++ b/compiler/testData/ir/irText/classes/implicitNotNullOnDelegatedImplementation.txt @@ -131,7 +131,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestJFoo modality:FINAL visibility:public superTypes:[.IFoo]' - FIELD DELEGATE name:TestJFoo$IFoo$delegate type:.JFoo visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.JFoo visibility:private [final] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor () [primary] declared in .JFoo' type=.JFoo origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestJFoo) returnType:kotlin.String @@ -142,7 +142,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestJFoo' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun foo (): kotlin.String declared in .JFoo' type=kotlin.String origin=null - $this: GET_FIELD 'FIELD DELEGATE name:TestJFoo$IFoo$delegate type:.JFoo visibility:private [final]' type=.JFoo origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.JFoo visibility:private [final]' type=.JFoo origin=null receiver: GET_VAR ': .TestJFoo declared in .TestJFoo.foo' type=.TestJFoo origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -163,7 +163,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK1 modality:FINAL visibility:public superTypes:[.IFoo]' - FIELD DELEGATE name:TestK1$IFoo$delegate type:.K1 visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.K1 visibility:private [final] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K1' type=.K1 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK1) returnType:kotlin.String @@ -174,7 +174,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK1' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun foo (): kotlin.String [fake_override] declared in .K1' type=kotlin.String origin=null - $this: GET_FIELD 'FIELD DELEGATE name:TestK1$IFoo$delegate type:.K1 visibility:private [final]' type=.K1 origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K1 visibility:private [final]' type=.K1 origin=null receiver: GET_VAR ': .TestK1 declared in .TestK1.foo' type=.TestK1 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -195,7 +195,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK2 modality:FINAL visibility:public superTypes:[.IFoo]' - FIELD DELEGATE name:TestK2$IFoo$delegate type:.K2 visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.K2 visibility:private [final] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K2' type=.K2 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK2) returnType:kotlin.String @@ -205,7 +205,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK2' CALL 'public open fun foo (): kotlin.String declared in .K2' type=kotlin.String origin=null - $this: GET_FIELD 'FIELD DELEGATE name:TestK2$IFoo$delegate type:.K2 visibility:private [final]' type=.K2 origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K2 visibility:private [final]' type=.K2 origin=null receiver: GET_VAR ': .TestK2 declared in .TestK2.foo' type=.TestK2 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -226,7 +226,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK3 modality:FINAL visibility:public superTypes:[.IFoo]' - FIELD DELEGATE name:TestK3$IFoo$delegate type:.K3 visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.K3 visibility:private [final] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K3' type=.K3 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK3) returnType:kotlin.String @@ -236,7 +236,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK3' CALL 'public open fun foo (): kotlin.String [fake_override] declared in .K3' type=kotlin.String origin=null - $this: GET_FIELD 'FIELD DELEGATE name:TestK3$IFoo$delegate type:.K3 visibility:private [final]' type=.K3 origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K3 visibility:private [final]' type=.K3 origin=null receiver: GET_VAR ': .TestK3 declared in .TestK3.foo' type=.TestK3 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: @@ -257,7 +257,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:TestK4 modality:FINAL visibility:public superTypes:[.IFoo]' - FIELD DELEGATE name:TestK4$IFoo$delegate type:.K4 visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.K4 visibility:private [final] EXPRESSION_BODY CONSTRUCTOR_CALL 'public constructor () [primary] declared in .K4' type=.K4 origin=null FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:.TestK4) returnType:kotlin.String @@ -268,7 +268,7 @@ FILE fqName: fileName:/implicitNotNullOnDelegatedImplementation.kt RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in .TestK4' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public open fun foo (): kotlin.String? declared in .K4' type=kotlin.String? origin=null - $this: GET_FIELD 'FIELD DELEGATE name:TestK4$IFoo$delegate type:.K4 visibility:private [final]' type=.K4 origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.K4 visibility:private [final]' type=.K4 origin=null receiver: GET_VAR ': .TestK4 declared in .TestK4.foo' type=.TestK4 origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: diff --git a/compiler/testData/ir/irText/declarations/kt35550.txt b/compiler/testData/ir/irText/declarations/kt35550.txt index b4633c020f9..dd50338c65c 100644 --- a/compiler/testData/ir/irText/declarations/kt35550.txt +++ b/compiler/testData/ir/irText/declarations/kt35550.txt @@ -30,7 +30,7 @@ FILE fqName: fileName:/kt35550.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:A modality:FINAL visibility:public superTypes:[.I]' - FIELD DELEGATE name:A$I$delegate type:.I visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.I visibility:private [final] EXPRESSION_BODY GET_VAR 'i: .I declared in .A.' type=.I origin=null PROPERTY DELEGATED_MEMBER name:id visibility:public modality:OPEN [val] @@ -45,7 +45,7 @@ FILE fqName: fileName:/kt35550.kt RETURN type=kotlin.Nothing from='public open fun (): T of .A. declared in .A' CALL 'public open fun (): T of .I. declared in .I' type=T of .A. origin=null : T of .A. - $this: GET_FIELD 'FIELD DELEGATE name:A$I$delegate type:.I visibility:private [final]' type=.I origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.I visibility:private [final]' type=.I origin=null receiver: GET_VAR ': .A declared in .A.' type=.A origin=null $receiver: GET_VAR ': T of .A. declared in .A.' type=T of .A. origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] diff --git a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt index b0463fa2a94..0919600addb 100644 --- a/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt +++ b/compiler/testData/ir/irText/declarations/parameters/delegatedMembers.txt @@ -35,7 +35,7 @@ FILE fqName: fileName:/delegatedMembers.kt BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test modality:FINAL visibility:public superTypes:[.IBase.Test>]' - FIELD DELEGATE name:Test$IBase$delegate type:.IBase.Test> visibility:private [final] + FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:private [final] EXPRESSION_BODY GET_VAR 'impl: .IBase.Test> declared in .Test.' type=.IBase.Test> origin=null FUN DELEGATED_MEMBER name:qux visibility:public modality:OPEN ($this:.Test.Test>, t:TT of .Test, x:X of .Test.qux) returnType:kotlin.Unit @@ -48,7 +48,7 @@ FILE fqName: fileName:/delegatedMembers.kt BLOCK_BODY CALL 'public abstract fun qux (t: T of .IBase, x: X of .IBase.qux): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null : X of .Test.qux - $this: GET_FIELD 'FIELD DELEGATE name:Test$IBase$delegate type:.IBase.Test> visibility:private [final]' type=.IBase.Test> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:private [final]' type=.IBase.Test> origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.qux' type=.Test.Test> origin=null t: GET_VAR 't: TT of .Test declared in .Test.qux' type=TT of .Test origin=null x: GET_VAR 'x: X of .Test.qux declared in .Test.qux' type=X of .Test.qux origin=null @@ -59,7 +59,7 @@ FILE fqName: fileName:/delegatedMembers.kt VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY CALL 'public abstract fun foo (x: kotlin.Int): kotlin.Unit declared in .IBase' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test$IBase$delegate type:.IBase.Test> visibility:private [final]' type=.IBase.Test> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:private [final]' type=.IBase.Test> origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.foo' type=.Test.Test> origin=null x: GET_VAR 'x: kotlin.Int declared in .Test.foo' type=kotlin.Int origin=null PROPERTY DELEGATED_MEMBER name:bar visibility:public modality:OPEN [val] @@ -71,7 +71,7 @@ FILE fqName: fileName:/delegatedMembers.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .Test' CALL 'public abstract fun (): kotlin.Int declared in .IBase' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:Test$IBase$delegate type:.IBase.Test> visibility:private [final]' type=.IBase.Test> origin=null + $this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:.IBase.Test> visibility:private [final]' type=.IBase.Test> origin=null receiver: GET_VAR ': .Test.Test> declared in .Test.' type=.Test.Test> origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: