Kotlin constructors generation vs Java constructors generation

For Java Intellij allows to generate constructors, but for Kotlin it doesn’t. Is it a bug or there is reason that doesn’t allow to generate constructors for Kotlin classes?
Java:


Kotlin:

1 Like

It’s not a bug, it’s just not implemented yet. Please submit a feature request at http://kotl.in/issue with sample code to reproduce in text form. Thanks!

@Void In case it helps, I could only see a similar option “[Generate] Secondary constructor” which shows me the list of all of the super constructors that I could override, and I could select them all so the IDE created them all for me. However, this option is visible only if there is no primary constructor defined for your class. When I added a primary constructor to mine, then Intellij wouldn’t show me the option to generate/override secondary constructors, which I don’t see why is that tbh, seems like a miss from the plugin devs.

Though anyway, I think this option is only helpful for when the constructors have very different arguments and do different things, however in the case of overriding them all for an Android’s ViewGroup, which seems to be your case, its 3 constructors are just one main constructor and 2 secondary ones which pass default values to the main one for convenience whenever the instantiator wouldn’t want to pass them all 3 params, they’d get the defaults for the others. In that case, I think you’re better off annotating your main constructor with JvmOverloads, that way you wouldn’t have to override them all constructors.

Feature requested here: https://youtrack.jetbrains.com/issue/IDEA-293228/Kotlin-IDE-Plugin:-Allow-generation-of-all-secondary-constructor