In Kotlin, you must override either both or neither of the equals(Any?) and hashCode() methods in order to keep the contract between the two:

By overriding only one of the two methods with a non-trivial implementation, this contract is almost certainly broken.

Noncompliant Code Example

class MyClass {    // Noncompliant - should also override "hashCode()"

  override fun equals(other: Any?): Boolean {
    /* ... */
  }

}

Compliant Solution

class MyClass {    // Compliant

  override fun equals(other: Any?): Boolean {
    /* ... */
  }

  override fun hashCode(): Int {
    /* ... */
  }

}

See