How to detect array of nullable type via annotation processor?


We can check a Nullable parameter by it.getAnnotation( != null at compile time.
But how to check an array’s element should be nullable or not at compile time via annotation processor .


There was a discussion about this already (Kotlin JS - annotations processor). We did not find a solution to check for nullability on generic parameters sadly. The problem is that the annotation processor only gives access to the java type descriptions, which do not contain any information about nullability. This should be solved once we get access to the Kotlin type information. I think JetBrains is planning an creating a better way of doing annotation processing which will give us access to those information, but as far as I remember they are not yet actively working on it (at least they did not tell us about it) and there is definitely no release date.


Actually, unless I misunderstood, you can use the @Metadata annotation to retrieve additional information on the different types used in your classes and functions. The video at and repo might help you :slight_smile:


Intersting I did not know about that one. But In my defence, the last time I looked into annotation processing was more than a year ago, so yeah.
And I can’t wait for the compiler plugins :blush: