I have this annotation : ```@Target(AnnotationTarg...
# ksp
j
I have this annotation :
Copy code
@Target(AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.SOURCE)
annotation class MyAnnotation(val myArgument: Boolean = false)
...
@MyAnnotation
val someVariable1: String

@MyAnnotation(myArgument = true)
val someVariable2: String
...
When I checked the value of the argument, I get
null
instead of
false
Copy code
val argumentValue = someVariable.annotations.first().arguments
logger.warn("${someVariable.simpleName.asString()} argumentValue: $argumentValue"")
...
w: [ksp] someVariable1 argumentValue: [myArgument:null]
w: [ksp] someVariable2 argumentValue: [myArgument:true]
Is that expected?
t
Looks like a bug to me. May I know the exact version of KSP? @Jiaxiang WDYT?
j
it’s also worth mentioning if you are building on a non jvm target, there is a known issue with non jvm platform annotation argument default value.
j
Copy code
kotlinVersion=1.8.0
kspVersion=1.8.0-1.0.8
It’s a kotlin multiplatform project but the issue occurs in a unit test on the jvm