diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/EqualsOrHashCodeInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/EqualsOrHashCodeInspection.kt index a08db2b84a9..30d981b0672 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/EqualsOrHashCodeInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/EqualsOrHashCodeInspection.kt @@ -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 -> { diff --git a/idea/testData/inspections/equalsAndHashCode/test.kt b/idea/testData/inspections/equalsAndHashCode/test.kt index 2bd043e6030..2d40a3cd466 100644 --- a/idea/testData/inspections/equalsAndHashCode/test.kt +++ b/idea/testData/inspections/equalsAndHashCode/test.kt @@ -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 } \ No newline at end of file