How can I check if my annotation type parameter of...
# ksp
p
How can I check if my annotation type parameter of type
KClass<*>
is assignable from a certain
KSClassDeclaration
?
1
It seems
KSType
has
isAssignableFrom
method, but I can get
KSType
from the annotation argument, but can’t figure out how to get
KSType
from
KSClassDeclaration
Solution: instead of using KSType it’s possible to get
KSClassDeclaration
via
Resolver::getClassDeclarationByName
and use its
KSClassDeclaration::getAllSuperTypes
method
d
Would calling
KSClassDeclaration.asType()
work? If you don’t need to supply type arguments for the type parameters,
asType(emptyList())
should work.