From 61063a19b63c2a8f1b7ac302317233d7763245b4 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Tue, 3 Oct 2023 16:07:25 +0200 Subject: [PATCH] [FIR] add missing transformation of backing field during annotation arguments phase ^KT-56551 --- .../propertyWithImplicitTypeAndFieldAnnotations.txt | 8 ++++---- ...propertyWithImplicitTypeAndFieldAnnotationsScript.txt | 9 +++++---- .../plugin/FirAnnotationArgumentsResolveTransformer.kt | 7 +++++++ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotations.txt b/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotations.txt index 315dfba71d8..e8138d24b80 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotations.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotations.txt @@ -217,8 +217,8 @@ FILE: [ResolvedTo(IMPORTS)] propertyWithImplicitTypeAndFieldAnnotations.kt public [ResolvedTo(STATUS)] get(): @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val setterParameterProperty: = LAZY_EXPRESSION public [ResolvedTo(STATUS)] get(): - @Anno[Unresolved](LAZY_EXPRESSION) public? final? const [ResolvedTo(RAW_FIR)] val fieldProperty: = LAZY_EXPRESSION - public? [ResolvedTo(RAW_FIR)] get(): + @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val fieldProperty: = LAZY_EXPRESSION + public [ResolvedTo(STATUS)] get(): @R|myPack/Anno|[Types](propertyProperty#) field:@FIELD:R|myPack/Anno|[Types](fieldProperty#) public final [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] var variableToResolve: = LAZY_EXPRESSION @R|myPack/Anno|[Types](getterProperty#) public [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] get(): { LAZY_BLOCK } @R|myPack/Anno|[Types](setterProperty#) public [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] set([ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] @R|myPack/Anno|[Types](setterParameterProperty#) value: ): R|kotlin/Unit| { LAZY_BLOCK } @@ -242,8 +242,8 @@ FILE: [ResolvedTo(IMPORTS)] propertyWithImplicitTypeAndFieldAnnotations.kt public [ResolvedTo(STATUS)] get(): @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val setterParameterProperty: = LAZY_EXPRESSION public [ResolvedTo(STATUS)] get(): - @Anno[Unresolved](LAZY_EXPRESSION) public? final? const [ResolvedTo(RAW_FIR)] val fieldProperty: = LAZY_EXPRESSION - public? [ResolvedTo(RAW_FIR)] get(): + @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val fieldProperty: = LAZY_EXPRESSION + public [ResolvedTo(STATUS)] get(): @R|myPack/Anno|[Types](propertyProperty#) field:@FIELD:R|myPack/Anno|[Types](fieldProperty#) public final [ResolvedTo(CONTRACTS)] var variableToResolve: = (IntegerLiteral(42)) @R|myPack/Anno|[Types](getterProperty#) public [ResolvedTo(CONTRACTS)] get(): { ^ field#.plus#(String(str)) diff --git a/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotationsScript.txt b/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotationsScript.txt index b16a25bcd09..f7035d0f6c7 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotationsScript.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/propertyWithImplicitTypeAndFieldAnnotationsScript.txt @@ -314,8 +314,8 @@ FILE: [ResolvedTo(IMPORTS)] propertyWithImplicitTypeAndFieldAnnotationsScript.kt @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val setterParameterProperty: = LAZY_EXPRESSION public [ResolvedTo(STATUS)] get(): - @Anno[Unresolved](LAZY_EXPRESSION) public? final? const [ResolvedTo(RAW_FIR)] val fieldProperty: = LAZY_EXPRESSION - public? [ResolvedTo(RAW_FIR)] get(): + @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val fieldProperty: = LAZY_EXPRESSION + public [ResolvedTo(STATUS)] get(): @R|myPack/Anno|[Types](propertyProperty#) field:@FIELD:R|myPack/Anno|[Types](fieldProperty#) public final [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] var variableToResolve: = LAZY_EXPRESSION @R|myPack/Anno|[Types](getterProperty#) public [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] get(): { LAZY_BLOCK } @@ -350,8 +350,8 @@ FILE: [ResolvedTo(IMPORTS)] propertyWithImplicitTypeAndFieldAnnotationsScript.kt @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val setterParameterProperty: = LAZY_EXPRESSION public [ResolvedTo(STATUS)] get(): - @Anno[Unresolved](LAZY_EXPRESSION) public? final? const [ResolvedTo(RAW_FIR)] val fieldProperty: = LAZY_EXPRESSION - public? [ResolvedTo(RAW_FIR)] get(): + @R|myPack/Anno|[Types](LAZY_EXPRESSION) public final const [ResolvedTo(STATUS)] val fieldProperty: = LAZY_EXPRESSION + public [ResolvedTo(STATUS)] get(): @R|myPack/Anno|[Types](propertyProperty#) field:@FIELD:R|myPack/Anno|[Types](fieldProperty#) public final [ResolvedTo(CONTRACTS)] var variableToResolve: = (IntegerLiteral(42)) @R|myPack/Anno|[Types](getterProperty#) public [ResolvedTo(CONTRACTS)] get(): { @@ -520,3 +520,4 @@ FILE: [ResolvedTo(BODY_RESOLVE)] propertyWithImplicitTypeAndFieldAnnotationsScri @R|myPack/Anno|[Types](number = R|myPack/setterProperty|) public [ResolvedTo(BODY_RESOLVE)] set([ResolvedTo(BODY_RESOLVE)] @R|myPack/Anno|[Types](number = R|myPack/setterParameterProperty|) value: R|kotlin/String|): R|kotlin/Unit| { ^ Q|kotlin/Unit| } + diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt index 83bbba02007..b1a34c0e2fa 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/plugin/FirAnnotationArgumentsResolveTransformer.kt @@ -129,9 +129,16 @@ private class FirDeclarationsResolveTransformerForArgumentAnnotations( .transformGetter(transformer, data) .transformSetter(transformer, data) .transformTypeParameters(transformer, data) + .transformBackingField(transformer, data) + return property } + override fun transformBackingField(backingField: FirBackingField, data: ResolutionMode): FirBackingField { + backingField.transformAnnotations(transformer, data) + return backingField + } + override fun transformPropertyAccessor( propertyAccessor: FirPropertyAccessor, data: ResolutionMode