[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:
committed by
Yan Zhulanow
parent
fbcde11b04
commit
212baf580c
+10
@@ -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
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
KtDeclaration: KtClass Foo
|
||||
annotations: [
|
||||
B(a = [/A, /A(value = [], )])
|
||||
psi: KtAnnotationEntry
|
||||
]
|
||||
analysis/analysis-api/testData/annotations/annotationsOnDeclaration/direct/varargComplexParameter.kt
Vendored
+5
@@ -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
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
KtDeclaration: KtClass Foo
|
||||
annotations: [
|
||||
AArray(value = [/A(strings = ["foo", "bar"], )])
|
||||
psi: KtAnnotationEntry
|
||||
]
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
annotation class A(vararg val strings: String)
|
||||
|
||||
@A(strings = ["foo", "bar"])
|
||||
class F<caret>oo
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
KtDeclaration: KtClass Foo
|
||||
annotations: [
|
||||
A(strings = ["foo", "bar"])
|
||||
psi: KtAnnotationEntry
|
||||
]
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
KtDeclaration: KtClass Foo
|
||||
annotations: [
|
||||
A(strings = [["foo", "bar"], "baz", ["quux"]])
|
||||
psi: KtAnnotationEntry
|
||||
]
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
annotation class A(vararg val strings: String)
|
||||
|
||||
@A(*arrayOf("foo", "bar"), "baz", *["quux"])
|
||||
class F<caret>oo
|
||||
analysis/analysis-api/testData/annotations/annotationsOnDeclaration/direct/varargSpreadParameter.txt
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
KtDeclaration: KtClass Foo
|
||||
annotations: [
|
||||
A(strings = ["foo", "bar", "baz", "quux"])
|
||||
psi: KtAnnotationEntry
|
||||
]
|
||||
Reference in New Issue
Block a user