data クラスにある Array 型のプロパティで、オーバーライドされた equals() または hashCode() がないものを報告します。

配列のパラメーターは参照の等価性によって比較されます。しかし、これは想定している動作ではないと思われます。 このような場合は、equals()hashCode() をオーバーライドすることを強くお勧めします。

例:


  data class Text(val lines: Array<String>)

クイックフィックスを使用すると、欠落している equals()hashCode() の実装が生成されます。


  data class Text(val lines: Array<String>) {
      override fun equals(other: Any?): Boolean {
          if (this === other) return true
          if (javaClass != other?.javaClass) return false

          other as Text

          if (!lines.contentEquals(other.lines)) return false

          return true
      }

      override fun hashCode(): Int {
          return lines.contentHashCode()
      }
  }