From 386e2e0950ab5aaa0405d1822b2786bd4e424f32 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 7 Dec 2021 10:41:57 +0300 Subject: [PATCH] FIR2IR: don't create separate delegate fields for constructor properties --- .../fir/backend/Fir2IrDeclarationStorage.kt | 44 ++++++++++++++----- .../kotlin/fir/backend/Fir2IrVisitor.kt | 6 ++- .../delegatedGenericImplementation.fir.ir.txt | 11 ++--- .../delegatedGenericImplementation.fir.kt.txt | 9 ++-- ...edImplementationOfJavaInterface.fir.ir.txt | 15 +++---- ...edImplementationOfJavaInterface.fir.kt.txt | 13 +++--- .../Fir2IrClassifierStorage.fir.ir.txt | 7 +-- .../Fir2IrClassifierStorage.fir.kt.txt | 5 +-- .../firProblems/SignatureClash.fir.ir.txt | 5 +-- .../firProblems/SignatureClash.fir.kt.txt | 3 +- .../ir/irText/firProblems/kt43342.fir.ir.txt | 19 ++++---- .../ir/irText/firProblems/kt43342.fir.kt.txt | 17 ++++--- 12 files changed, 80 insertions(+), 74 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt index fdcc5dd45ca..0bc49f6e8c1 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.fir.backend +import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.builtins.StandardNames.BUILT_INS_PACKAGE_FQ_NAMES import org.jetbrains.kotlin.descriptors.DescriptorVisibility @@ -20,10 +21,7 @@ import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.descriptors.FirBuiltInsPackageFragment import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor import org.jetbrains.kotlin.fir.descriptors.FirPackageFragmentDescriptor -import org.jetbrains.kotlin.fir.expressions.FirComponentCall -import org.jetbrains.kotlin.fir.expressions.FirConstExpression -import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess +import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyConstructor @@ -945,17 +943,41 @@ class Fir2IrDeclarationStorage( fun getCachedIrField(field: FirField): IrField? = fieldCache[field] - fun createIrFieldAndDelegatedMembers(field: FirField, owner: FirClass, irClass: IrClass): IrField { - val irField = createIrField( - field, - typeRef = field.initializer?.typeRef ?: field.returnTypeRef, - origin = IrDeclarationOrigin.DELEGATE - ) - irField.setAndModifyParent(irClass) + fun createIrFieldAndDelegatedMembers(field: FirField, owner: FirClass, irClass: IrClass): IrField? { + // Either take a corresponding constructor property backing field, + // or create a separate delegate field + val irField = getOrCreateDelegateIrField(field, owner, irClass) delegatedMemberGenerator.generate(irField, field, owner, irClass) if (owner.isLocalClassOrAnonymousObject()) { delegatedMemberGenerator.generateBodies() } + // If it's a property backing field, it should not be added to the class in Fir2IrConverter, so it's not returned + return irField.takeIf { it.correspondingPropertySymbol == null } + } + + private fun getOrCreateDelegateIrField(field: FirField, owner: FirClass, irClass: IrClass): IrField { + val initializer = field.initializer + if (initializer is FirQualifiedAccessExpression && initializer.explicitReceiver == null) { + val resolvedSymbol = initializer.calleeReference.resolvedSymbol as? FirValueParameterSymbol + if (resolvedSymbol is FirValueParameterSymbol) { + val name = resolvedSymbol.name + val constructorProperty = owner.declarations.filterIsInstance().find { + it.name == name && it.source?.kind is KtFakeSourceElementKind.PropertyFromParameter + } + if (constructorProperty != null) { + val irProperty = getOrCreateIrProperty(constructorProperty, irClass) + val backingField = irProperty.backingField!! + fieldCache[field] = backingField + return backingField + } + } + } + val irField = createIrField( + field, + typeRef = initializer?.typeRef ?: field.returnTypeRef, + origin = IrDeclarationOrigin.DELEGATE + ) + irField.setAndModifyParent(irClass) return irField } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index bc3b4e5c8f9..8802891780e 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -76,7 +76,11 @@ class Fir2IrVisitor( override fun visitField(field: FirField, data: Any?): IrField { if (field.isSynthetic) { return declarationStorage.getCachedIrField(field)!!.apply { - memberGenerator.convertFieldContent(this, field) + // If this is a property backing field, then it has no separate initializer, + // so we shouldn't convert it + if (correspondingPropertySymbol == null) { + memberGenerator.convertFieldContent(this, field) + } } } else { throw AssertionError("Unexpected field: ${field.render()}") diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt index 3d4a764b356..9f2366c9fac 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.ir.txt @@ -142,7 +142,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:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' 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 @@ -160,7 +160,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:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' 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] @@ -177,7 +177,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:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' 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 @@ -191,13 +191,10 @@ 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:<$$delegate_0> type:.IBase visibility:local [final]' type=.IBase origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private' 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 - FIELD DELEGATE name:<$$delegate_0> type:.IBase visibility:local [final] - EXPRESSION_BODY - GET_VAR 'j: .IBase declared in .Test2.' type=.IBase origin=null PROPERTY name:j visibility:public modality:FINAL [var] FIELD PROPERTY_BACKING_FIELD name:j type:.IBase visibility:private EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt index 25803ef7550..89c5a4c5217 100644 --- a/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedGenericImplementation.fir.kt.txt @@ -45,23 +45,22 @@ class Test2 : IBase { } override fun foo(a: String, b: B) { - .#<$$delegate_0>.foo(a = a, b = b) + .#j.foo(a = a, b = b) } override val C.id: Map? override get(): Map? { - return (.#<$$delegate_0>, ).() + return (.#j, ).() } override var List.x: D? override get(): D? { - return (.#<$$delegate_0>, ).() + return (.#j, ).() } override set(: D?) { - (.#<$$delegate_0>, ).( = ) + (.#j, ).( = ) } - local /* final field */ val <$$delegate_0>: IBase = j var j: IBase field = j get diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.ir.txt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.ir.txt index 6207a88aaf3..4da0c629691 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.ir.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.ir.txt @@ -13,7 +13,7 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt VALUE_PARAMETER name:x index:0 type:@[EnhancedNullability] kotlin.String BLOCK_BODY CALL 'public abstract fun takeNotNull (x: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .Test declared in .Test.takeNotNull' type=.Test origin=null x: GET_VAR 'x: @[EnhancedNullability] kotlin.String declared in .Test.takeNotNull' type=@[EnhancedNullability] kotlin.String origin=null FUN DELEGATED_MEMBER name:takeNullable visibility:public modality:OPEN <> ($this:.Test, x:kotlin.String?) returnType:kotlin.Unit @@ -23,7 +23,7 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt VALUE_PARAMETER name:x index:0 type:kotlin.String? BLOCK_BODY CALL 'public abstract fun takeNullable (x: kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .Test declared in .Test.takeNullable' type=.Test origin=null x: GET_VAR 'x: kotlin.String? declared in .Test.takeNullable' type=kotlin.String? origin=null FUN DELEGATED_MEMBER name:takeFlexible visibility:public modality:OPEN <> ($this:.Test, x:@[FlexibleNullability] kotlin.String?) returnType:kotlin.Unit @@ -33,7 +33,7 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt VALUE_PARAMETER name:x index:0 type:@[FlexibleNullability] kotlin.String? BLOCK_BODY CALL 'public abstract fun takeFlexible (x: @[FlexibleNullability] kotlin.String?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .Test declared in .Test.takeFlexible' type=.Test origin=null x: GET_VAR 'x: @[FlexibleNullability] kotlin.String? declared in .Test.takeFlexible' type=@[FlexibleNullability] kotlin.String? origin=null FUN DELEGATED_MEMBER name:returnNotNull visibility:public modality:OPEN <> ($this:.Test) returnType:@[EnhancedNullability] kotlin.String @@ -46,7 +46,7 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt RETURN type=kotlin.Nothing from='public open fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in .Test' TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String CALL 'public abstract fun returnNotNull (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .Test declared in .Test.returnNotNull' type=.Test origin=null FUN DELEGATED_MEMBER name:returnNullable visibility:public modality:OPEN <> ($this:.Test) returnType:kotlin.String? annotations: @@ -57,7 +57,7 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun returnNullable (): kotlin.String? declared in .Test' CALL 'public abstract fun returnNullable (): kotlin.String? declared in .J' type=kotlin.String? origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .Test declared in .Test.returnNullable' type=.Test origin=null FUN DELEGATED_MEMBER name:returnsFlexible visibility:public modality:OPEN <> ($this:.Test) returnType:@[FlexibleNullability] kotlin.String? overridden: @@ -66,11 +66,8 @@ FILE fqName: fileName:/delegatedImplementationOfJavaInterface.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in .Test' CALL 'public abstract fun returnsFlexible (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final]' type=.J origin=null receiver: GET_VAR ': .Test declared in .Test.returnsFlexible' type=.Test origin=null - FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final] - EXPRESSION_BODY - GET_VAR 'j: .J declared in .Test.' type=.J origin=null PROPERTY name:j visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:j type:.J visibility:private [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt index 6c591cbe73e..829068f54fb 100644 --- a/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt +++ b/compiler/testData/ir/irText/classes/delegatedImplementationOfJavaInterface.fir.kt.txt @@ -6,32 +6,31 @@ class Test : J { } override fun takeNotNull(x: @EnhancedNullability String) { - .#<$$delegate_0>.takeNotNull(x = x) + .#j.takeNotNull(x = x) } override fun takeNullable(x: String?) { - .#<$$delegate_0>.takeNullable(x = x) + .#j.takeNullable(x = x) } override fun takeFlexible(x: @FlexibleNullability String?) { - .#<$$delegate_0>.takeFlexible(x = x) + .#j.takeFlexible(x = x) } @NotNull override fun returnNotNull(): @EnhancedNullability String { - return .#<$$delegate_0>.returnNotNull() /*!! String */ + return .#j.returnNotNull() /*!! String */ } @Nullable override fun returnNullable(): String? { - return .#<$$delegate_0>.returnNullable() + return .#j.returnNullable() } override fun returnsFlexible(): @FlexibleNullability String? { - return .#<$$delegate_0>.returnsFlexible() + return .#j.returnsFlexible() } - local /* final field */ val <$$delegate_0>: J = j private val j: J field = j private get diff --git a/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.ir.txt b/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.ir.txt index 74be316122a..a45725edede 100644 --- a/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.ir.txt @@ -127,7 +127,7 @@ FILE fqName: fileName:/Fir2IrClassifierStorage.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): .FirSession declared in .Fir2IrClassifierStorage' CALL 'public abstract fun (): .FirSession declared in .Fir2IrComponents' type=.FirSession origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.Fir2IrComponents visibility:local [final]' type=.Fir2IrComponents origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:components type:.Fir2IrComponents visibility:private [final]' type=.Fir2IrComponents origin=null receiver: GET_VAR ': .Fir2IrClassifierStorage declared in .Fir2IrClassifierStorage.' type=.Fir2IrClassifierStorage origin=null PROPERTY DELEGATED_MEMBER name:classifierStorage visibility:public modality:OPEN [val] overridden: @@ -140,11 +140,8 @@ FILE fqName: fileName:/Fir2IrClassifierStorage.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): .Fir2IrClassifierStorage declared in .Fir2IrClassifierStorage' CALL 'public abstract fun (): .Fir2IrClassifierStorage declared in .Fir2IrComponents' type=.Fir2IrClassifierStorage origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.Fir2IrComponents visibility:local [final]' type=.Fir2IrComponents origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:components type:.Fir2IrComponents visibility:private [final]' type=.Fir2IrComponents origin=null receiver: GET_VAR ': .Fir2IrClassifierStorage declared in .Fir2IrClassifierStorage.' type=.Fir2IrClassifierStorage origin=null - FIELD DELEGATE name:<$$delegate_0> type:.Fir2IrComponents visibility:local [final] - EXPRESSION_BODY - GET_VAR 'components: .Fir2IrComponents declared in .Fir2IrClassifierStorage.' type=.Fir2IrComponents origin=null PROPERTY name:components visibility:private modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:components type:.Fir2IrComponents visibility:private [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.kt.txt b/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.kt.txt index f73b371eb74..835c18f3d3c 100644 --- a/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/Fir2IrClassifierStorage.fir.kt.txt @@ -46,15 +46,14 @@ class Fir2IrClassifierStorage : Fir2IrComponents { override val session: FirSession override get(): FirSession { - return .#<$$delegate_0>.() + return .#components.() } override val classifierStorage: Fir2IrClassifierStorage override get(): Fir2IrClassifierStorage { - return .#<$$delegate_0>.() + return .#components.() } - local /* final field */ val <$$delegate_0>: Fir2IrComponents = components private val components: Fir2IrComponents field = components private get diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.ir.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.ir.txt index 7e5a5f84ba8..3af7283cf62 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.ir.txt @@ -96,11 +96,8 @@ FILE fqName: fileName:/SignatureClash.kt $this: VALUE_PARAMETER name: type:.DataClass BLOCK_BODY CALL 'public abstract fun bar (): kotlin.Unit declared in .Delegate' type=kotlin.Unit origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.Delegate visibility:local [final]' type=.Delegate origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:delegate type:.Delegate visibility:private [final]' type=.Delegate origin=null receiver: GET_VAR ': .DataClass declared in .DataClass.bar' type=.DataClass origin=null - FIELD DELEGATE name:<$$delegate_0> type:.Delegate visibility:local [final] - EXPRESSION_BODY - GET_VAR 'delegate: .Delegate declared in .DataClass.' type=.Delegate origin=null PROPERTY name:delegate visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:delegate type:.Delegate visibility:private [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt index 8e59eaa7d2d..658296fec27 100644 --- a/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/SignatureClash.fir.kt.txt @@ -37,10 +37,9 @@ data class DataClass : Derived, Delegate { } override fun bar() { - .#<$$delegate_0>.bar() + .#delegate.bar() } - local /* final field */ val <$$delegate_0>: Delegate = delegate val delegate: Delegate field = delegate get diff --git a/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt b/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt index 1435868ae49..1fd7a4a50a9 100644 --- a/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt +++ b/compiler/testData/ir/irText/firProblems/kt43342.fir.ir.txt @@ -16,7 +16,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun containsKey (key: K of .ControlFlowInfo): kotlin.Boolean declared in .ControlFlowInfo' CALL 'public abstract fun containsKey (key: K of kotlin.collections.Map): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.containsKey' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null key: GET_VAR 'key: K of .ControlFlowInfo declared in .ControlFlowInfo.containsKey' type=K of .ControlFlowInfo origin=null FUN DELEGATED_MEMBER name:containsValue visibility:public modality:OPEN <> ($this:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo>, value:V of .ControlFlowInfo) returnType:kotlin.Boolean @@ -27,7 +27,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun containsValue (value: V of .ControlFlowInfo): kotlin.Boolean declared in .ControlFlowInfo' CALL 'public abstract fun containsValue (value: V of kotlin.collections.Map): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.containsValue' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null value: GET_VAR 'value: V of .ControlFlowInfo declared in .ControlFlowInfo.containsValue' type=V of .ControlFlowInfo origin=null FUN DELEGATED_MEMBER name:get visibility:public modality:OPEN <> ($this:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo>, key:K of .ControlFlowInfo) returnType:V of .ControlFlowInfo? [operator] @@ -38,7 +38,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun get (key: K of .ControlFlowInfo): V of .ControlFlowInfo? [operator] declared in .ControlFlowInfo' CALL 'public abstract fun get (key: K of kotlin.collections.Map): V of kotlin.collections.Map? [operator] declared in kotlin.collections.Map' type=V of .ControlFlowInfo? origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.get' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null key: GET_VAR 'key: K of .ControlFlowInfo declared in .ControlFlowInfo.get' type=K of .ControlFlowInfo origin=null FUN DELEGATED_MEMBER name:isEmpty visibility:public modality:OPEN <> ($this:.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo>) returnType:kotlin.Boolean @@ -48,7 +48,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun isEmpty (): kotlin.Boolean declared in .ControlFlowInfo' CALL 'public abstract fun isEmpty (): kotlin.Boolean declared in kotlin.collections.Map' type=kotlin.Boolean origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.isEmpty' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY DELEGATED_MEMBER name:entries visibility:public modality:OPEN [val] overridden: @@ -61,7 +61,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Set.ControlFlowInfo, V of .ControlFlowInfo>> declared in .ControlFlowInfo' CALL 'public abstract fun (): kotlin.collections.Set> declared in kotlin.collections.Map' type=kotlin.collections.Set.ControlFlowInfo, V of .ControlFlowInfo>> origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY DELEGATED_MEMBER name:keys visibility:public modality:OPEN [val] overridden: @@ -74,7 +74,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Set.ControlFlowInfo> declared in .ControlFlowInfo' CALL 'public abstract fun (): kotlin.collections.Set declared in kotlin.collections.Map' type=kotlin.collections.Set.ControlFlowInfo> origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY DELEGATED_MEMBER name:size visibility:public modality:OPEN [val] overridden: @@ -87,7 +87,7 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.Int declared in .ControlFlowInfo' CALL 'public abstract fun (): kotlin.Int declared in kotlin.collections.Map' type=kotlin.Int origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY DELEGATED_MEMBER name:values visibility:public modality:OPEN [val] overridden: @@ -100,11 +100,8 @@ FILE fqName: fileName:/kt43342.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): kotlin.collections.Collection.ControlFlowInfo> declared in .ControlFlowInfo' CALL 'public abstract fun (): kotlin.collections.Collection declared in kotlin.collections.Map' type=kotlin.collections.Collection.ControlFlowInfo> origin=null - $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null + $this: GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final]' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null receiver: GET_VAR ': .ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=.ControlFlowInfo.ControlFlowInfo, V of .ControlFlowInfo> origin=null - FIELD DELEGATE name:<$$delegate_0> type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:local [final] - EXPRESSION_BODY - GET_VAR 'map: kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> declared in .ControlFlowInfo.' type=kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> origin=null PROPERTY name:map visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:map type:kotlin.collections.Map.ControlFlowInfo, V of .ControlFlowInfo> visibility:private [final] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/firProblems/kt43342.fir.kt.txt b/compiler/testData/ir/irText/firProblems/kt43342.fir.kt.txt index 5b5b4be2334..afe942a34e6 100644 --- a/compiler/testData/ir/irText/firProblems/kt43342.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/kt43342.fir.kt.txt @@ -6,42 +6,41 @@ open class ControlFlowInfo : Map { } override fun containsKey(key: K): Boolean { - return .#<$$delegate_0>.containsKey(key = key) + return .#map.containsKey(key = key) } override fun containsValue(value: V): Boolean { - return .#<$$delegate_0>.containsValue(value = value) + return .#map.containsValue(value = value) } override operator fun get(key: K): V? { - return .#<$$delegate_0>.get(key = key) + return .#map.get(key = key) } override fun isEmpty(): Boolean { - return .#<$$delegate_0>.isEmpty() + return .#map.isEmpty() } override val entries: Set> override get(): Set> { - return .#<$$delegate_0>.() + return .#map.() } override val keys: Set override get(): Set { - return .#<$$delegate_0>.() + return .#map.() } override val size: Int override get(): Int { - return .#<$$delegate_0>.() + return .#map.() } override val values: Collection override get(): Collection { - return .#<$$delegate_0>.() + return .#map.() } - local /* final field */ val <$$delegate_0>: Map = map val map: Map field = map get