You can't execute target code during the processing phase (or else it will be a chicken and egg problem).
KSFunctionDeclarationImpl is a representation of the structure of the function, it's not the function and does not hold a reference to the function pointer (afaik).
glureau
03/03/2023, 1:46 PM
Maybe if you can generalize the problem we can offer some other solutions than the annotation parameter (I think it's unlikely but without more context I can't tell).
j
jean
03/03/2023, 1:56 PM
I’m just trying to generate a bunch of boiler code based on some configuration values. Maybe KSP isn’t the best for that. Or I need to put the config values in the annotation
j
Jiaxiang
03/03/2023, 9:55 PM
Your best option is to put it in the annotation. Casting as KFunction will never work because it is at compile time no reflection information is available, you can also try to write a custom compiler plugin but the complexity around evaluating expression can go unexpected, i.e. won’t scale well either.