[FIR] Init packageFqName when calculating lazy arguments of anotations

^KT-58584 fixed

Merge-request: KT-MR-10113
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
Egor Kulikov
2023-05-11 22:00:09 +00:00
committed by Space Team
parent 4c69f2fbcb
commit 34db304ef7
5 changed files with 164 additions and 1 deletions
@@ -71,7 +71,9 @@ private fun replaceValueParameterDefaultValues(valueParameters: List<FirValuePar
private fun calculateLazyArgumentsForAnnotation(annotationCall: FirAnnotationCall, session: FirSession) {
require(needCalculatingAnnotationCall(annotationCall))
val builder = RawFirBuilder(session, baseScopeProvider = session.kotlinScopeProvider)
val newAnnotationCall = builder.buildAnnotationCall(annotationCall.psi as KtAnnotationEntry)
val ktAnnotationEntry = annotationCall.psi as KtAnnotationEntry
builder.context.packageFqName = ktAnnotationEntry.containingKtFile.packageFqName
val newAnnotationCall = builder.buildAnnotationCall(ktAnnotationEntry)
annotationCall.replaceArgumentList(newAnnotationCall.argumentList)
}
@@ -0,0 +1,4 @@
@Anno(fun a() : String {
}())
class Top<caret>LevelClass
@@ -0,0 +1,145 @@
RAW_FIR:
FILE: [ResolvedTo(RAW_FIR)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] class TopLevelClass : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
IMPORTS:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] class TopLevelClass : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
COMPILER_REQUIRED_ANNOTATIONS:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] class TopLevelClass : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
COMPANION_GENERATION:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPANION_GENERATION)] class TopLevelClass : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
SUPER_TYPES:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@Anno[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(SUPER_TYPES)] class TopLevelClass : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
TYPES:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types](LAZY_EXPRESSION) public? final? [ResolvedTo(TYPES)] class TopLevelClass : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
STATUS:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types](LAZY_EXPRESSION) public final [ResolvedTo(STATUS)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
EXPECT_ACTUAL_MATCHING:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types](LAZY_EXPRESSION) public final [ResolvedTo(EXPECT_ACTUAL_MATCHING)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
ARGUMENTS_OF_ANNOTATIONS:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types](ERROR_EXPR(Incorrect invoke receiver)local final? [ResolvedTo(RAW_FIR)] fun a(): String {
}
.invoke#()) public final [ResolvedTo(ARGUMENTS_OF_ANNOTATIONS)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
CONTRACTS:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types](ERROR_EXPR(Incorrect invoke receiver)local final? [ResolvedTo(RAW_FIR)] fun a(): String {
}
.invoke#()) public final [ResolvedTo(CONTRACTS)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
IMPLICIT_TYPES_BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types](ERROR_EXPR(Incorrect invoke receiver)local final? [ResolvedTo(RAW_FIR)] fun a(): String {
}
.invoke#()) public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
ANNOTATIONS_ARGUMENTS_MAPPING:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types]() public final [ResolvedTo(ANNOTATIONS_ARGUMENTS_MAPPING)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
LAZY_super<R|kotlin/Any|>
}
}
BODY_RESOLVE:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(RAW_FIR)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types]() public final [ResolvedTo(BODY_RESOLVE)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
super<R|kotlin/Any|>()
}
}
FILE RAW TO BODY:
FILE: [ResolvedTo(IMPORTS)] annotationWithNamedFunctionArgument.kt
[ResolvedTo(BODY_RESOLVE)] annotations container
@<ERROR TYPE REF: Symbol not found for Anno>[Types]() public final [ResolvedTo(BODY_RESOLVE)] class TopLevelClass : R|kotlin/Any| {
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=TopLevelClass] constructor(): R|TopLevelClass| {
super<R|kotlin/Any|>()
}
}
@@ -523,6 +523,12 @@ public class FirOutOfContentRootLazyDeclarationResolveTestGenerated extends Abst
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/lazyResolve/errors"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("annotationWithNamedFunctionArgument.kt")
public void testAnnotationWithNamedFunctionArgument() throws Exception {
runTest("analysis/low-level-api-fir/testdata/lazyResolve/errors/annotationWithNamedFunctionArgument.kt");
}
@Test
@TestMetadata("anonymousObjectInInvalidPosition.kt")
public void testAnonymousObjectInInvalidPosition() throws Exception {
@@ -523,6 +523,12 @@ public class FirSourceLazyDeclarationResolveTestGenerated extends AbstractFirSou
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/lazyResolve/errors"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("annotationWithNamedFunctionArgument.kt")
public void testAnnotationWithNamedFunctionArgument() throws Exception {
runTest("analysis/low-level-api-fir/testdata/lazyResolve/errors/annotationWithNamedFunctionArgument.kt");
}
@Test
@TestMetadata("anonymousObjectInInvalidPosition.kt")
public void testAnonymousObjectInInvalidPosition() throws Exception {