Kotlin already has reflection for what you are ask...
# language-proposals
e
Kotlin already has reflection for what you are asking. It many not be as convenient for your particular use-case, but it works.