[FIR2IR] Generate annotations on delegated property accessors

^KT-64466 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-01-11 13:41:09 +02:00
committed by Space Team
parent 50abaaff7e
commit 6dd0992288
4 changed files with 32 additions and 1 deletions
@@ -400,7 +400,15 @@ class DelegatedMemberGenerator(private val components: Fir2IrComponents) : Fir2I
baseSymbols.add(it)
}
basePropertySymbols[delegateProperty] = baseSymbols
// Do not generate annotations to copy K1 behavior, see KT-57228.
// Do not generate annotations on property to copy K1 behavior, see KT-57228.
// But generate annotations on accessors, see KT-64466.
firDelegateProperty.getter?.let { firGetter ->
annotationGenerator.generate(delegateProperty.getter!!, firGetter)
}
firDelegateProperty.setter?.let { firSetter ->
annotationGenerator.generate(delegateProperty.setter!!, firSetter)
}
return delegateProperty
}
@@ -92,6 +92,8 @@ FILE fqName:<root> fileName:/annotationsOnDelegatedMembers.kt
overridden:
public abstract propWithAccessors: kotlin.Int
FUN DELEGATED_MEMBER name:<get-propWithAccessors> visibility:public modality:OPEN <> ($this:<root>.Delegated) returnType:kotlin.Int
annotations:
Ann
correspondingProperty: PROPERTY DELEGATED_MEMBER name:propWithAccessors visibility:public modality:OPEN [var]
overridden:
public abstract fun <get-propWithAccessors> (): kotlin.Int declared in <root>.Base
@@ -102,6 +104,8 @@ FILE fqName:<root> fileName:/annotationsOnDelegatedMembers.kt
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.Base visibility:private [final]' type=<root>.Base origin=null
receiver: GET_VAR '<this>: <root>.Delegated declared in <root>.Delegated.<get-propWithAccessors>' type=<root>.Delegated origin=null
FUN DELEGATED_MEMBER name:<set-propWithAccessors> visibility:public modality:OPEN <> ($this:<root>.Delegated, <set-?>:kotlin.Int) returnType:kotlin.Unit
annotations:
Ann
correspondingProperty: PROPERTY DELEGATED_MEMBER name:propWithAccessors visibility:public modality:OPEN [var]
overridden:
public abstract fun <set-propWithAccessors> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>.Base
@@ -42,9 +42,11 @@ class Delegated : Base {
}
override var propWithAccessors: Int
@Ann
override get(): Int {
return <this>.#$$delegate_0.<get-propWithAccessors>()
}
@Ann
override set(<set-?>: Int) {
<this>.#$$delegate_0.<set-propWithAccessors>(<set-?> = <set-?>)
}
@@ -36,6 +36,10 @@ class Delegated : Base {
// Mangled name: Delegated#<get-prop>(){}kotlin.Int
// Public signature: /Delegated.prop.<get-prop>|-2094203252476742575[0]
// Public signature debug description: <get-prop>(){}kotlin.Int
// CHECK JS_IR NATIVE:
// Mangled name: Delegated#<get-prop>(){}
// Public signature: /Delegated.prop.<get-prop>|-5734736374948136327[0]
// Public signature debug description: <get-prop>(){}
override get(): Int
// CHECK:
@@ -47,6 +51,10 @@ class Delegated : Base {
// Mangled name: Delegated#<get-propWithAccessors>(){}kotlin.Int
// Public signature: /Delegated.propWithAccessors.<get-propWithAccessors>|1392907778891534138[0]
// Public signature debug description: <get-propWithAccessors>(){}kotlin.Int
// CHECK JS_IR NATIVE:
// Mangled name: Delegated#<get-propWithAccessors>(){}
// Public signature: /Delegated.propWithAccessors.<get-propWithAccessors>|5253508570158188209[0]
// Public signature debug description: <get-propWithAccessors>(){}
@Ann
override get(): Int
// CHECK:
@@ -79,6 +87,10 @@ interface Base {
// Mangled name: Base#<get-prop>(){}kotlin.Int
// Public signature: /Base.prop.<get-prop>|-2094203252476742575[0]
// Public signature debug description: <get-prop>(){}kotlin.Int
// CHECK JS_IR NATIVE:
// Mangled name: Base#<get-prop>(){}
// Public signature: /Base.prop.<get-prop>|-5734736374948136327[0]
// Public signature debug description: <get-prop>(){}
abstract get
// CHECK:
@@ -90,6 +102,10 @@ interface Base {
// Mangled name: Base#<get-propWithAccessors>(){}kotlin.Int
// Public signature: /Base.propWithAccessors.<get-propWithAccessors>|1392907778891534138[0]
// Public signature debug description: <get-propWithAccessors>(){}kotlin.Int
// CHECK JS_IR NATIVE:
// Mangled name: Base#<get-propWithAccessors>(){}
// Public signature: /Base.propWithAccessors.<get-propWithAccessors>|5253508570158188209[0]
// Public signature debug description: <get-propWithAccessors>(){}
@Ann
abstract get
// CHECK:
@@ -100,3 +116,4 @@ interface Base {
abstract set
}