Back to Intellij Community

DestructingShortFormNameMismatch

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

2025.3-rc-2835 B
Original Source

Reports destructuring declarations where variable names don't match the original property names from data classes.

Example:

data class Product(val id: String, val productName: String)
  val (id, name) = product // warning on "name"

The following quick-fixes are available:

  • Rename variable to match property: val (id, productName) = product
  • Use positional destructuring with square brackets: val [id, name] = product

For standard library classes like Pair, Triple, and IndexedValue, the inspection suggests using positional destructuring syntax since these types are designed for positional access rather than name-based matching.

This inspection prepares code for an upcoming Kotlin language feature change where val (x, y) = e syntax will flip from position-based to name-based destructuring.