Back to Intellij Community

ConvertSecondaryConstructorToPrimary

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/ConvertSecondaryConstructorToPrimary.html

2025.3-rc-2314 B
Original Source

Reports a secondary constructor that can be replaced with a more concise primary constructor.

Example:

class User {
      val name: String

      constructor(name: String) {
          this.name = name
      }
  }

The quick-fix converts code automatically:

class User(val name: String) {
  }