KSP: how can I get the default value of a data class property?

985 Views Asked by At

I have the following data class annotated with @MyAnnotation:

@MyAnnotation
data class MyDataClass(
    val foo: Boolean = true,
    val bar: Int = 123,
    val buz: String? = "abc",
)

From the ClassDeclaration I can get all the KSPropertyDeclaration, and I'm able to get the simpleName and resolve the KSType, but I don't know how to get the default values of each property.

1

There are 1 best solutions below

2
On

Currently it's not supported by google, please check here https://github.com/google/ksp/issues/642