`null` value in annotation arguments if annotation originates from Java and argument is Kotlin's `const val`
See original GitHub issueAssume we have a Kotlin source, named Constants.kt
, as follows:
const val FOO = "foo"
And a Java source:
class Bar {
@Named(ConstantsKt.FOO) void set(/* */) { /* */ }
}
When @Named
annotation (KSAnnotationJavaImpl
) is resolved, it yields ["value:null"]
from its arguments
property, with no way to retrieve the "foo"
value.
Named = javax.inject.Named for completeness.
So, basically, Kotlin constants are not properly resolved in Java annotation arguments.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Kotlin Annotations
If we need to specify that an annotation parameter may have multiple values, then we just pass an array of those values:
Read more >Kotlin Annotation IntDef
So i have tried it, and made an annotation for this, but it won't show in autocompletion. My question: - Is Java annotation...
Read more >Nullability in Java and Kotlin
Nullability is the ability of a variable to hold a null value. ... If your Java code doesn't have these annotations, then Kotlin...
Read more >Improve code inspection with annotations
For example, if a local variable that contains a null value is passed as a parameter to a method with the @NonNull annotation...
Read more >Chapter 10. Annotations and reflection - Kotlin in Action
For example, a Kotlin property corresponds to a Java field, a getter, and possibly a setter and its parameter. A property declared in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Also this leaves us with the fundamental problem - how to model synthetic file facades in KSP, if they are used as classes directly, like in
@SomeAnnotation(clazz = ConstantsKt.class)
. For now we are gettingErrorType
there.Thanks for the fix!