[AA-FIR] Fix handling of Java annotation parameters.

This changes FirAnnotationValueConverter to no longer rely on PSI
information when projecting annotation parameter information to AA.
For annotations defined in Java, including many meta-annotations, PSI
information is not available for the annotation. This caused those
annotation values to be projected as KtUnsupportedAnnotationValue.

Instead of using PSI information, this changes
FirAnnotationValueConverter to use the tree structure instead. Spread
and named parameter arguments are spliced into the parameter list of
their surrounding vararg calls, meaning that callers see the expected
structure. (See the varargSpreadParameter.kt test file for an example.)
This commit is contained in:
Justin Paupore
2022-12-08 14:42:11 -08:00
committed by Yan Zhulanow
parent fbcde11b04
commit 212baf580c
19 changed files with 169 additions and 32 deletions
@@ -0,0 +1,10 @@
// FILE: A.java
public @interface A {
String[] value() default {"foo", "bar"};
}
// FILE: Test.kt
annotation class B(vararg val a: A)
@B(A(), A(*[]))
class <caret>Foo
@@ -0,0 +1,5 @@
KtDeclaration: KtClass Foo
annotations: [
B(a = [/A, /A(value = [], )])
psi: KtAnnotationEntry
]
@@ -0,0 +1,5 @@
annotation class A(vararg val strings: String)
annotation class AArray(vararg val value: A)
@AArray(A(strings = ["foo", "bar"]))
class F<caret>oo
@@ -0,0 +1,5 @@
KtDeclaration: KtClass Foo
annotations: [
AArray(value = [/A(strings = ["foo", "bar"], )])
psi: KtAnnotationEntry
]
@@ -0,0 +1,4 @@
annotation class A(vararg val strings: String)
@A(strings = ["foo", "bar"])
class F<caret>oo
@@ -0,0 +1,5 @@
KtDeclaration: KtClass Foo
annotations: [
A(strings = ["foo", "bar"])
psi: KtAnnotationEntry
]
@@ -0,0 +1,5 @@
KtDeclaration: KtClass Foo
annotations: [
A(strings = [["foo", "bar"], "baz", ["quux"]])
psi: KtAnnotationEntry
]
@@ -0,0 +1,4 @@
annotation class A(vararg val strings: String)
@A(*arrayOf("foo", "bar"), "baz", *["quux"])
class F<caret>oo
@@ -0,0 +1,5 @@
KtDeclaration: KtClass Foo
annotations: [
A(strings = ["foo", "bar", "baz", "quux"])
psi: KtAnnotationEntry
]