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 bcba9cba205..9cde0e2074e 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 @@ -11,6 +11,7 @@ import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toPersistentList import org.jetbrains.kotlin.KtFakeSourceElementKind import org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDesignation +import org.jetbrains.kotlin.analysis.low.level.api.fir.util.forEachDependentDeclaration import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.builder.PsiRawFirBuilder import org.jetbrains.kotlin.fir.contracts.FirRawContractDescription @@ -660,6 +661,15 @@ private object FirTargetLazyAnnotationCalculatorTransformer : FirLazyAnnotationT return regularClass } + override fun transformScript(script: FirScript, data: FirLazyAnnotationTransformerData): FirScript { + script.transformAnnotations(this, data) + script.forEachDependentDeclaration { + it.transformSingle(this, data) + } + + return script + } + override fun transformBlock(block: FirBlock, data: FirLazyAnnotationTransformerData): FirStatement { // We shouldn't process blocks because there are no lazy annotations return block diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/annotations/annotationApplicationArgumentOnStatement.txt b/analysis/low-level-api-fir/testData/getOrBuildFir/annotations/annotationApplicationArgumentOnStatement.txt index fad2b37142d..02ce98bdde6 100644 --- a/analysis/low-level-api-fir/testData/getOrBuildFir/annotations/annotationApplicationArgumentOnStatement.txt +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/annotations/annotationApplicationArgumentOnStatement.txt @@ -11,7 +11,7 @@ FILE: [ResolvedTo(IMPORTS)] annotationApplicationArgumentOnStatement.kts SCRIPT: [ResolvedTo(BODY_RESOLVE)] [ResolvedTo(BODY_RESOLVE)] lval args: R|kotlin/Array| - @R|kotlin/annotation/Target|[Types](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @R|kotlin/annotation/Retention|[Types](AnnotationRetention#.SOURCE#) public final [ResolvedTo(STATUS)] annotation class Annotation : R|kotlin/Annotation| { + @R|kotlin/annotation/Target|[Types](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @R|kotlin/annotation/Retention|[Types](LAZY_EXPRESSION) public final [ResolvedTo(STATUS)] annotation class Annotation : R|kotlin/Annotation| { public [ResolvedTo(STATUS)] [ContainingClassKey=Annotation] constructor([ResolvedTo(STATUS)] [CorrespondingProperty=/Annotation.name] name: R|kotlin/String|): R|Annotation| { LAZY_super } @@ -25,4 +25,4 @@ FILE: [ResolvedTo(IMPORTS)] annotationApplicationArgumentOnStatement.kts } public final [ResolvedTo(BODY_RESOLVE)] val $$result: R|kotlin/Unit| = @R|Annotation|[Types](name = String(y)) R|/x|() - public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Unit| + public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Unit| \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/lazyResolve/properties/scriptWithTypeAnnotationsOnDeclaration.txt b/analysis/low-level-api-fir/testData/lazyResolve/properties/scriptWithTypeAnnotationsOnDeclaration.txt index dc938f0392a..98c375060de 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/properties/scriptWithTypeAnnotationsOnDeclaration.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/properties/scriptWithTypeAnnotationsOnDeclaration.txt @@ -224,7 +224,7 @@ FILE: [ResolvedTo(IMPORTS)] scriptWithTypeAnnotationsOnDeclaration.kts SCRIPT: [ResolvedTo(ANNOTATION_ARGUMENTS)] [ResolvedTo(RAW_FIR)] lval args: R|kotlin/Array| - @Target[Unresolved](AnnotationTarget#.TYPE#) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { + @Target[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=foo/Anno.position] position: String): R|foo/Anno| { LAZY_super } @@ -237,7 +237,7 @@ FILE: [ResolvedTo(IMPORTS)] scriptWithTypeAnnotationsOnDeclaration.kts public? final? const [ResolvedTo(RAW_FIR)] val constant: = LAZY_EXPRESSION public? [ResolvedTo(RAW_FIR)] get(): - public? final? [ResolvedTo(RAW_FIR)] fun explicitType(): @Anno[Unresolved]((String(return type: ), constant#)) List<@Anno[Unresolved]((String(nested return type: ), constant#)) Collection<@Anno[Unresolved]((String(nested nested return type: ), constant#)) String>> { LAZY_BLOCK } + public? final? [ResolvedTo(RAW_FIR)] fun explicitType(): @Anno[Unresolved](LAZY_EXPRESSION) List<@Anno[Unresolved](LAZY_EXPRESSION) Collection<@Anno[Unresolved](LAZY_EXPRESSION) String>> { LAZY_BLOCK } BODY_RESOLVE: @@ -246,7 +246,7 @@ FILE: [ResolvedTo(IMPORTS)] scriptWithTypeAnnotationsOnDeclaration.kts SCRIPT: [ResolvedTo(BODY_RESOLVE)] [ResolvedTo(BODY_RESOLVE)] lval args: R|kotlin/Array| - @Target[Unresolved](AnnotationTarget#.TYPE#) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { + @Target[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=foo/Anno.position] position: String): R|foo/Anno| { LAZY_super } @@ -259,7 +259,7 @@ FILE: [ResolvedTo(IMPORTS)] scriptWithTypeAnnotationsOnDeclaration.kts public? final? const [ResolvedTo(RAW_FIR)] val constant: = LAZY_EXPRESSION public? [ResolvedTo(RAW_FIR)] get(): - public? final? [ResolvedTo(RAW_FIR)] fun explicitType(): @Anno[Unresolved]((String(return type: ), constant#)) List<@Anno[Unresolved]((String(nested return type: ), constant#)) Collection<@Anno[Unresolved]((String(nested nested return type: ), constant#)) String>> { LAZY_BLOCK } + public? final? [ResolvedTo(RAW_FIR)] fun explicitType(): @Anno[Unresolved](LAZY_EXPRESSION) List<@Anno[Unresolved](LAZY_EXPRESSION) Collection<@Anno[Unresolved](LAZY_EXPRESSION) String>> { LAZY_BLOCK } FILE RAW TO BODY: @@ -284,3 +284,4 @@ FILE: [ResolvedTo(BODY_RESOLVE)] scriptWithTypeAnnotationsOnDeclaration.kts public final [ResolvedTo(BODY_RESOLVE)] fun explicitType(): R|@R|foo/Anno|(position = (String(return type: ), R|foo/constant|)) kotlin/collections/List<@R|foo/Anno|(position = (String(nested return type: ), R|foo/constant|)) kotlin/collections/Collection<@R|foo/Anno|(position = (String(nested nested return type: ), R|foo/constant|)) kotlin/String>>| { ^explicitType Int(0) } + diff --git a/analysis/low-level-api-fir/testData/lazyResolve/script.txt b/analysis/low-level-api-fir/testData/lazyResolve/script.txt index 5695d4679d3..ce9d2de9594 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/script.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/script.txt @@ -584,7 +584,7 @@ FILE: [ResolvedTo(IMPORTS)] script.kts } - @Target[Unresolved](AnnotationTarget#.EXPRESSION#, AnnotationTarget#.FUNCTION#) @Retention[Unresolved](AnnotationRetention#.SOURCE#) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { + @Target[Unresolved](LAZY_EXPRESSION, LAZY_EXPRESSION) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| { public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/Anno.s] s: En): R|Anno| { LAZY_super } @@ -594,13 +594,13 @@ FILE: [ResolvedTo(IMPORTS)] script.kts } - @Anno[Unresolved](En#.Entry#) public? final? [ResolvedTo(RAW_FIR)] fun build([ResolvedTo(RAW_FIR)] action: ( Builder.() -> Unit )): { LAZY_BLOCK } + @Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] fun build([ResolvedTo(RAW_FIR)] action: ( Builder.() -> Unit )): { LAZY_BLOCK } - @Anno[Unresolved](En#.Entry#) build#( = LAZY_EXPRESSION) + @Anno[Unresolved](LAZY_EXPRESSION) build#( = LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] val builder: = LAZY_EXPRESSION public? [ResolvedTo(RAW_FIR)] get(): - @Anno[Unresolved](En#.Entry#) builder#.execute#() + @Anno[Unresolved](LAZY_EXPRESSION) builder#.execute#() builder#.version# = String() BODY_RESOLVE: @@ -641,7 +641,7 @@ FILE: [ResolvedTo(IMPORTS)] script.kts } - @R|kotlin/annotation/Target|[Types](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|, Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.FUNCTION|) @R|kotlin/annotation/Retention|[Types](AnnotationRetention#.SOURCE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { + @R|kotlin/annotation/Target|[Types](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|, Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.FUNCTION|) @R|kotlin/annotation/Retention|[Types](LAZY_EXPRESSION) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| { public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] constructor([ResolvedTo(STATUS)] [CorrespondingProperty=/Anno.s] s: R|En|): R|Anno| { LAZY_super } @@ -651,7 +651,7 @@ FILE: [ResolvedTo(IMPORTS)] script.kts } - @R|Anno|[Types](En#.Entry#) public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun build([ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] action: R|Builder.() -> kotlin/Unit|): R|Builder| { + @R|Anno|[Types](LAZY_EXPRESSION) public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun build([ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] action: R|Builder.() -> kotlin/Unit|): R|Builder| { ^build R|/Builder.Builder|().R|kotlin/apply|(R|/action|) }