From b7df9ec05a0d61549712ca37d09b9c248465d7b7 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 18 Jun 2020 18:59:23 +0300 Subject: [PATCH] Implement equals/hashCode as this class previously was a `data` one Fixes duplicated diagnostics in tests --- .../kotlin/resolve/deprecation/Deprecation.kt | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/Deprecation.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/Deprecation.kt index 8547f6e2f4b..0786a219ffe 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/Deprecation.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/Deprecation.kt @@ -47,6 +47,24 @@ internal sealed class DeprecatedByAnnotation( "HIDDEN" -> HIDDEN else -> WARNING } + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is StandardDeprecated) return false + + if (annotation != other.annotation) return false + if (target != other.target) return false + if (propagatesToOverrides != other.propagatesToOverrides) return false + + return true + } + + override fun hashCode(): Int { + var hash = annotation.hashCode() + hash = hash * 31 + target.hashCode() + hash = hash * 31 + propagatesToOverrides.hashCode() + return hash + } } class DeprecatedSince( @@ -54,7 +72,27 @@ internal sealed class DeprecatedByAnnotation( target: DeclarationDescriptor, propagatesToOverrides: Boolean, override val deprecationLevel: DeprecationLevelValue - ) : DeprecatedByAnnotation(annotation, target, propagatesToOverrides) + ) : DeprecatedByAnnotation(annotation, target, propagatesToOverrides) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is DeprecatedSince) return false + + if (annotation != other.annotation) return false + if (target != other.target) return false + if (propagatesToOverrides != other.propagatesToOverrides) return false + if (deprecationLevel != other.deprecationLevel) return false + + return true + } + + override fun hashCode(): Int { + var hash = annotation.hashCode() + hash = hash * 31 + target.hashCode() + hash = hash * 31 + propagatesToOverrides.hashCode() + hash = hash * 31 + deprecationLevel.hashCode() + return hash + } + } companion object { fun create(