Inspectopedia Help

Recursive equals call

Reports recursive equals (==) calls.

In Kotlin, == compares object values by calling equals method under the hood. ===, on the other hand, compares objects by reference.

=== is commonly used in equals method implementation. But === may be mistakenly mixed up with == leading to infinite recursion.

Example:

class X { override fun equals(other: Any?): Boolean { if (this == other) return true return false } }

After the quick-fix is applied:

class X { override fun equals(other: Any?): Boolean { if (this === other) return true return false } }

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Kotlin, 241.16690-IJ

Last modified: 29 April 2024