-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Annotation values that are default are not visible in KSP #53
Comments
android/kotlin#60 contains a partial fix. With that commit you will be able to see the name of the missing argument, but not able to find out the default value of that argument. Still working to find a solution to find the default value. |
i think this bug might already be fixed? |
actually nevermind, looks like it is still broken for defaults values w/ other annotations. |
Yes, it is broken for annotations declared in kotlin and then compiled. |
KSP cannot always read default values in annotations. This CL introduces a new XAnnotationBox implementation that uses reflection instead to workaround it. Unfortunately, KSP's behavior does not let us distinguish between null vs default or empty array vs default. In both cases, we prefer going to the default value in the annotation if value is required. Also added support for enum lists in the java annotation box implementation. google/ksp#53 Bug: 160322705 Test: XAnnotationBoxTest, KspReflectiveAnnotationBoxTest Change-Id: Ic38ef8cae000a00f96b99425b9e266cddcae48cb
fixed in #528 |
Unfortunateely this still looks broken in beta07. |
fixed in #591 |
I think I ran into an edge case in 1.0 where, even with this fix, I get a null default value in the case where a class is defined within the annotation class. Happens with both kotlin and java - here is a kotlin example.
Moving the object outside the annotation class fixes the problem |
is the above class from a compiled library? |
Yes, the annotation class is defined in a compiled library. |
thanks, I'll create a separate issue to track. |
When reading a Java annotation with default value, its value is not visible in the arguments list.
If you annotate an element with
JavaAnnotation
and don't specify awithDefaultValue
property, KSP processor threats it as not existing such that arguments map in KSAnnotation will only includedebug
field.The text was updated successfully, but these errors were encountered: