Implement equals/hashCode as this class previously was a data one

Fixes duplicated diagnostics in tests
This commit is contained in:
Mikhail Zarechenskiy
2020-06-18 18:59:23 +03:00
parent a2da00eb49
commit b7df9ec05a
@@ -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(