From ea8a645513c6c34856b2e29323e9c2ca77216ff1 Mon Sep 17 00:00:00 2001 From: Dmitrii Gridin Date: Mon, 20 Nov 2023 12:50:17 +0100 Subject: [PATCH] [LL FIR] FirLazyBodiesCalculator: do not touch declarations during file annotation calculation It leads to many problems in concurrent case. E.g., we can transform the status of a declaration without the lock ^KT-62947 Fixed --- .../level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt | 5 +++++ .../testData/lazyResolve/fileElements.txt | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt index 9cde0e2074e..e6bdce91fda 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/lazy/resolve/FirLazyBodiesCalculator.kt @@ -674,6 +674,11 @@ private object FirTargetLazyAnnotationCalculatorTransformer : FirLazyAnnotationT // We shouldn't process blocks because there are no lazy annotations return block } + + override fun transformFile(file: FirFile, data: FirLazyAnnotationTransformerData): FirFile { + file.transformAnnotationsContainer(this, data) + return file + } } private abstract class FirLazyAnnotationTransformer : FirTransformer() { diff --git a/analysis/low-level-api-fir/testData/lazyResolve/fileElements.txt b/analysis/low-level-api-fir/testData/lazyResolve/fileElements.txt index 8245485f843..55250cdabef 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/fileElements.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/fileElements.txt @@ -409,7 +409,7 @@ FILE: [ResolvedTo(ANNOTATION_ARGUMENTS)] fileElements.kt public? final? [ResolvedTo(RAW_FIR)] val c: = LAZY_EXPRESSION public? [ResolvedTo(RAW_FIR)] get(): public? final? [ResolvedTo(RAW_FIR)] fun test1(): R|kotlin/Unit| { LAZY_BLOCK } - @Deprecated[Unresolved](String()) @Anno[Unresolved](IntegerLiteral(2)) public? final? [ResolvedTo(RAW_FIR)] fun test2(): R|kotlin/Unit| { LAZY_BLOCK } + @Deprecated[Unresolved](LAZY_EXPRESSION) @Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] fun test2(): R|kotlin/Unit| { LAZY_BLOCK } public? final? [ResolvedTo(RAW_FIR)] class A : R|kotlin/Any| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=A] constructor(): R|one/A| { LAZY_super @@ -420,7 +420,7 @@ FILE: [ResolvedTo(ANNOTATION_ARGUMENTS)] fileElements.kt @Deprecated[Unresolved](LAZY_EXPRESSION) @Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] fun test4(): R|kotlin/Unit| { LAZY_BLOCK } } - @Anno[Unresolved](IntegerLiteral(4)) @Deprecated[Unresolved](String()) public? final? [ResolvedTo(RAW_FIR)] class B : R|kotlin/Any| { + @Anno[Unresolved](LAZY_EXPRESSION) @Deprecated[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] class B : R|kotlin/Any| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=B] constructor(): R|one/B| { LAZY_super } @@ -448,7 +448,7 @@ FILE: [ResolvedTo(BODY_RESOLVE)] fileElements.kt public final [ResolvedTo(BODY_RESOLVE)] val c: R|kotlin/Int| = R|one/b|.R|kotlin/Int.plus|(R|one/a|) public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int| public? final? [ResolvedTo(RAW_FIR)] fun test1(): R|kotlin/Unit| { LAZY_BLOCK } - @Deprecated[Unresolved](String()) @Anno[Unresolved](IntegerLiteral(2)) public? final? [ResolvedTo(RAW_FIR)] fun test2(): R|kotlin/Unit| { LAZY_BLOCK } + @Deprecated[Unresolved](LAZY_EXPRESSION) @Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] fun test2(): R|kotlin/Unit| { LAZY_BLOCK } public? final? [ResolvedTo(RAW_FIR)] class A : R|kotlin/Any| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=A] constructor(): R|one/A| { LAZY_super @@ -459,7 +459,7 @@ FILE: [ResolvedTo(BODY_RESOLVE)] fileElements.kt @Deprecated[Unresolved](LAZY_EXPRESSION) @Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] fun test4(): R|kotlin/Unit| { LAZY_BLOCK } } - @Anno[Unresolved](IntegerLiteral(4)) @Deprecated[Unresolved](String()) public? final? [ResolvedTo(RAW_FIR)] class B : R|kotlin/Any| { + @Anno[Unresolved](LAZY_EXPRESSION) @Deprecated[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] class B : R|kotlin/Any| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=B] constructor(): R|one/B| { LAZY_super }