diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt index ceb35f23aed..dadfeb23c3d 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/transformers/LLFirTargetResolver.kt @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.util.checkPhase import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElementWithResolveState -import org.jetbrains.kotlin.fir.FirFileAnnotationsContainer import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.FirConstructor import org.jetbrains.kotlin.fir.declarations.FirDeclaration @@ -135,8 +134,7 @@ internal abstract class LLFirTargetResolver( * @see skipDependencyTargetResolutionStep */ private fun resolveDependencies(target: FirElementWithResolveState) { - if (skipDependencyTargetResolutionStep || target is FirFileAnnotationsContainer) return - resolveTarget.firFile?.annotationsContainer?.lazyResolveToPhase(resolverPhase) + if (skipDependencyTargetResolutionStep) return val originalDeclaration = (target as? FirCallableDeclaration)?.originalIfFakeOverrideOrDelegated() when { @@ -160,6 +158,9 @@ internal abstract class LLFirTargetResolver( target is FirField && target.origin == FirDeclarationOrigin.Synthetic.DelegateField || target is FirConstructor -> { containingClass(target).lazyResolveToPhase(resolverPhase) } + + // Effectively, file annotation container is a part of FirFile, so we have to resolve it before + target is FirFile -> target.annotationsContainer?.lazyResolveToPhase(resolverPhase) } } diff --git a/analysis/low-level-api-fir/testData/lazyResolve/annotations.txt b/analysis/low-level-api-fir/testData/lazyResolve/annotations.txt index 244a5d8fddf..3b2580b3729 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/annotations.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/annotations.txt @@ -13,64 +13,64 @@ FILE: [ResolvedTo(IMPORTS)] annotations.kt COMPILER_REQUIRED_ANNOTATIONS: FILE: [ResolvedTo(IMPORTS)] annotations.kt @FILE:Suppress[Unresolved](LAZY_EXPRESSION) - [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotations container + [ResolvedTo(RAW_FIR)] annotations container @Suppress[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } COMPANION_GENERATION: FILE: [ResolvedTo(IMPORTS)] annotations.kt @FILE:Suppress[Unresolved](LAZY_EXPRESSION) - [ResolvedTo(COMPANION_GENERATION)] annotations container + [ResolvedTo(RAW_FIR)] annotations container @Suppress[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPANION_GENERATION)] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } SUPER_TYPES: FILE: [ResolvedTo(IMPORTS)] annotations.kt @FILE:Suppress[Unresolved](LAZY_EXPRESSION) - [ResolvedTo(SUPER_TYPES)] annotations container + [ResolvedTo(RAW_FIR)] annotations container @Suppress[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(SUPER_TYPES)] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } TYPES: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](LAZY_EXPRESSION) - [ResolvedTo(TYPES)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](LAZY_EXPRESSION) public? final? [ResolvedTo(TYPES)] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } STATUS: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](LAZY_EXPRESSION) - [ResolvedTo(STATUS)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](LAZY_EXPRESSION) public final [ResolvedTo(STATUS)] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } EXPECT_ACTUAL_MATCHING: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](LAZY_EXPRESSION) - [ResolvedTo(EXPECT_ACTUAL_MATCHING)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](LAZY_EXPRESSION) public final [ResolvedTo(EXPECT_ACTUAL_MATCHING)] fun resolveMe(): R|kotlin/Unit| { LAZY_BLOCK } CONTRACTS: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](LAZY_EXPRESSION) - [ResolvedTo(CONTRACTS)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](LAZY_EXPRESSION) public final [ResolvedTo(CONTRACTS)] fun resolveMe(): R|kotlin/Unit| { } IMPLICIT_TYPES_BODY_RESOLVE: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](LAZY_EXPRESSION) - [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](LAZY_EXPRESSION) public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun resolveMe(): R|kotlin/Unit| { } ANNOTATION_ARGUMENTS: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](names = vararg(String(1))) - [ResolvedTo(ANNOTATION_ARGUMENTS)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](names = vararg(String(2))) public final [ResolvedTo(ANNOTATION_ARGUMENTS)] fun resolveMe(): R|kotlin/Unit| { } BODY_RESOLVE: FILE: [ResolvedTo(IMPORTS)] annotations.kt - @FILE:R|kotlin/Suppress|[Types](names = vararg(String(1))) - [ResolvedTo(ANNOTATION_ARGUMENTS)] annotations container + @FILE:Suppress[Unresolved](LAZY_EXPRESSION) + [ResolvedTo(RAW_FIR)] annotations container @R|kotlin/Suppress|[Types](names = vararg(String(2))) public final [ResolvedTo(BODY_RESOLVE)] fun resolveMe(): R|kotlin/Unit| { } diff --git a/analysis/low-level-api-fir/testData/lazyResolve/annotationsScript.txt b/analysis/low-level-api-fir/testData/lazyResolve/annotationsScript.txt index be83e37952e..663e5562e55 100644 --- a/analysis/low-level-api-fir/testData/lazyResolve/annotationsScript.txt +++ b/analysis/low-level-api-fir/testData/lazyResolve/annotationsScript.txt @@ -23,7 +23,7 @@ FILE: [ResolvedTo(IMPORTS)] annotationsScript.kts COMPILER_REQUIRED_ANNOTATIONS: FILE: [ResolvedTo(IMPORTS)] annotationsScript.kts @FILE:Suppress[Unresolved](LAZY_EXPRESSION) - [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotations container + [ResolvedTo(RAW_FIR)] annotations container context(