Is there a way to duplicate all constructors in th...
# compiler
g
Is there a way to duplicate all constructors in the class on the front-end? The problem I am solving is to add a parameter to all constructors of annotated class. As far as I know, there is no way to change declarations on the front-end. And the recommended way is to add new constructors deprecating old ones. But I don't see a way to get list of all old constructors without entering infinite loop. Or is it better to add new functions to companion object or something similar instead of new constructors?
j
You can do that with FIR
g
How? I tried using
FirDeclarationGenerationExtension
. But I always end up in infinite loop. For example, if I try to get all constructors inside
generateConstructors
method via
context.owner.constructors(session)
, I'll enter infinite loop. Because to get all constructors this
generateConstructors
method will be called. I have to somehow separate user-defined constructors from generated ones without attempt to list the last ones.