```//Module A public class MyJavaClass { public ...
# ksp
v
Copy code
//Module A
public class MyJavaClass {
  public @interface MyAnnotation {}
}

//Module B with KSP Processor
class MyKotlinClass(@MyJavaClass.MyAnnotation val myProp: Any)
Hi! In my KSP Processor I’m trying to resolve
KSTypeReference
of annotation type
MyJavaClass.MyAnnotation
which I face during analysis of `MyKotlinClass`’s constructor and for some reason it could not be resolved (
KSType#isError
returns true). If I move
MyAnnotation
to the top-level everything works fine. I am not sure how I can debug this issue, any ideas? =\
cc: @Jiaxiang
At the same time if I try to get nested class via
resolver.getClassDeclarationByName
by its FQCN everything works just fine, so I think it means that theoretically it could be resolved
j
sorry can you clarify your issue? It looks like in your snippet
MyAnnotation
is already at top level? Do you mean you are not able to resolve the type when the annotation is on the constructor parameter?
v
I am not able to resolve the type of annotation when it is being declared as a nested class. In the snippet above
MyAnnotation
is declared inside
MyJavaClass
. So it’s canonical name is
MyJavaClass$MyAnnotation
. When I declare
MyAnnotation
at the top-level, so its canonical name becomes just
MyAnnotation
(assuming I am using default empty package there) it could be resolved just fine.
j
could be a known issue: https://github.com/google/ksp/issues/1034 which only happens with 1.7.0, can you try 1.6.21 to see if this issue goes away?
v
Yeah, sorry for not specifying the version, I’m on
1.6.21-1.0.5
updating loading
Nope, didn’t help =(
@Jiaxiang update, the same thing happens when nested annotation comes from kotlin file, so it looks like it has nothing to do with java 😞
j
Thanks for the update. I’ll need another look then.