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 | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023