Inspections: Forbid equals/hashCode inspection on object with explicit supertypes

#KT-9778 Fixed
This commit is contained in:
Alexey Sedunov
2015-11-19 20:31:57 +03:00
parent d652623f90
commit b6a5d30469
2 changed files with 12 additions and 0 deletions
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.psi.KtObjectDeclaration
import org.jetbrains.kotlin.psi.KtVisitorVoid
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.types.typeUtil.supertypes
object DeleteEqualsAndHashCodeFix : LocalQuickFix {
override fun getName() = "Delete equals()/hashCode()"
@@ -76,6 +77,7 @@ class EqualsOrHashCodeInspection : AbstractKotlinInspection() {
when (classDescriptor.kind) {
ClassKind.OBJECT -> {
if (classOrObject.getDelegationSpecifiers().isNotEmpty()) return
holder.registerProblem(nameIdentifier, "equals()/hashCode() in object declaration", DeleteEqualsAndHashCodeFix)
}
ClassKind.CLASS -> {
+10
View File
@@ -36,4 +36,14 @@ interface I {
enum E {
override fun equals(other: Any?) = true
override fun hashCode() = 0
}
abstract class T
object O4 : A() {
override fun equals(other: Any?) = true
}
object O5 : A() {
override fun hashCode() = 0
}