You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MyClass<T> {
var myList: @JvmSuppressWildcards List<Foo> = TODO()
}
If I resolve the property type, it has the @JvmSuppressWildcards annotation as expected. However, if I use KSType#replace() or KSPropertyDeclaration#asMemberOf() the resulting type does not have the @JvmSuppressWildcards annotation.
It's also interesting that in the later 2 cases the annotation still shows up in the KSType#toString() but just not in KSType#annotations. Poking around at the internals, I noticed that the annotations are still available in the type via KSTypeImpl.getKotlinType().getAnnotations().hasAnnotations(FQName), so one workaround at the moment is to use reflection to check for the annotation.
The text was updated successfully, but these errors were encountered:
This CL fixes a few issues:
1. Adds logic to keep track of the synthetic `getFoo$annotations()`
method using kotlin metadata, and automatically adds the
annotations to the associated `JavacFieldElement`.
2. `KspType` now keeps track of the "original annotations" of a type
(or type argument) to work around the bug described in
google/ksp#1376. That bug is technically
fixed, but hasn't landed in an official release yet.
3. Fixes the `acceptedTargets` for methods and constructors to include
`AnnotationTarget.FUNCTION` and `AnnotationTarget.CONSTRUCTOR`
respectively.
4. Changes the `acceptedTargets` for fields to include both
`AnnotationTarget.FIELD` and `AnnotationTarget.PROPERTY`. This seems
to be more intuitive than only accepting `FIELD` since `XFieldElement`
kind of represents both.
5. Fixes type annotations on `KspTypeElement`'s super class and
super interfaces in KSP
Test: XAnnotationTest.kt
Change-Id: I3c57e8169f30310f6d8dbdd5e7a741dfd9dc5e48
Say I have a property like the one below:
If I resolve the property type, it has the
@JvmSuppressWildcards
annotation as expected. However, if I useKSType#replace()
orKSPropertyDeclaration#asMemberOf()
the resulting type does not have the@JvmSuppressWildcards
annotation.Example:
It's also interesting that in the later 2 cases the annotation still shows up in the
KSType#toString()
but just not inKSType#annotations
. Poking around at the internals, I noticed that the annotations are still available in the type viaKSTypeImpl.getKotlinType().getAnnotations().hasAnnotations(FQName)
, so one workaround at the moment is to use reflection to check for the annotation.The text was updated successfully, but these errors were encountered: