[LL FIR] add getOrBuildFir test on destructuring declaration annotation

It doesn't resolve the property as it is treated as a local one

^KT-62840
This commit is contained in:
Dmitrii Gridin
2024-02-09 19:35:37 +01:00
committed by Space Team
parent 9ca0bdcb80
commit 792af849df
3 changed files with 64 additions and 0 deletions
@@ -0,0 +1,8 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtAnnotationEntry
data class MyPair(val a: Int, val b: Int)
const val prop = 0
annotation class DestrAnno(val s: String)
<expr>@DestrAnno("destr 1 $prop")</expr>
val (a, b) = MyPair(1, 2)
@@ -0,0 +1,50 @@
KT element: KtAnnotationEntry
FIR element: FirAnnotationCallImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
@DestrAnno[Unresolved](LAZY_EXPRESSION)
FIR FILE:
FILE: [ResolvedTo(IMPORTS)] destructuringAnnotation.kts
context(<script>@kotlin.script.templates.standard.ScriptTemplateWithArgs)
SCRIPT: [ResolvedTo(RAW_FIR)] <script-destructuringAnnotation.kts>
[ResolvedTo(RAW_FIR)] lval args: R|kotlin/Array<kotlin/String>|
public final? data [ResolvedTo(RAW_FIR)] class MyPair : R|kotlin/Any| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyPair] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/MyPair.a] a: Int, [ResolvedTo(RAW_FIR)] [CorrespondingProperty=/MyPair.b] b: Int): R|MyPair| {
LAZY_super<R|kotlin/Any|>
}
public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=/MyPair.component1, IsFromPrimaryConstructor=true] val a: Int = R|<local>/a|
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyPair] get(): Int
public? final? [ResolvedTo(RAW_FIR)] [ComponentFunctionSymbolKey=/MyPair.component2, IsFromPrimaryConstructor=true] val b: Int = R|<local>/b|
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyPair] get(): Int
public? final operator [ResolvedTo(RAW_FIR)] fun component1(): Int
public? final operator [ResolvedTo(RAW_FIR)] fun component2(): Int
public final [ResolvedTo(RAW_FIR)] fun copy([ResolvedTo(RAW_FIR)] a: Int = this@R|/MyPair|.R|/MyPair.a|, [ResolvedTo(RAW_FIR)] b: Int = this@R|/MyPair|.R|/MyPair.b|): R|MyPair|
}
public? final? const [ResolvedTo(RAW_FIR)] val prop: <implicit> = LAZY_EXPRESSION
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
public final? [ResolvedTo(RAW_FIR)] annotation class DestrAnno : R|kotlin/Annotation| {
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DestrAnno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=/DestrAnno.s] s: String): R|DestrAnno| {
LAZY_super<R|kotlin/Any|>
}
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val s: String = R|<local>/s|
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=DestrAnno] get(): String
}
@DestrAnno[Unresolved](LAZY_EXPRESSION) [ResolvedTo(RAW_FIR)] [DestructuringDeclarationContainerVariableMarkerKey=true] lval <destruct>: <implicit> = LAZY_EXPRESSION
public final [ResolvedTo(RAW_FIR)] [DestructuringDeclarationContainerVariableKey=<local>/<destruct>] val a: <implicit> = R|<local>/<destruct>|.component1#()
public final [ResolvedTo(RAW_FIR)] [DestructuringDeclarationContainerVariableKey=<local>/<destruct>] val b: <implicit> = R|<local>/<destruct>|.component2#()
@@ -57,6 +57,12 @@ public class ScriptGetOrBuildFirTestGenerated extends AbstractScriptGetOrBuildFi
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/annotations/annotationOnReturnTypeScript.kts");
}
@Test
@TestMetadata("destructuringAnnotation.kts")
public void testDestructuringAnnotation() throws Exception {
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/annotations/destructuringAnnotation.kts");
}
@Test
@TestMetadata("fileAnnotationScript.kts")
public void testFileAnnotationScript() throws Exception {