Closed ansman closed 5 months ago
We're seeing this as well
As a workaround you can get the underlying annotations field and surface a fake delegating class
val reflectiveAnnotations =
@Suppress("UNCHECKED_CAST")
(AbstractKSDeclarationImpl::class
.java
.getDeclaredField("originalAnnotations\$delegate")
.apply { isAccessible = true }
.get(entry) as Lazy<Sequence<KSAnnotation>>)
.value
val newClassWithAnnotations =
object : KSClassDeclaration by entry {
override val annotations: Sequence<KSAnnotation>
get() = reflectiveAnnotations
}
I have a test case in my annotation processor that reads the annotations on enum entires. When trying it on K2 with KSP2, the test fails. Upon investigating, it's because there are no annotations present.
The enum in question looks like this:
I dumped all annotations on all declarations using this:
and this is what's printed:
On KSP1, this is logged: