From 4530cdefe5aa4141ea905fd5cae25baf9f5aa5ab Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 31 Aug 2020 17:41:36 +0300 Subject: [PATCH] [FIR] Implement proper equals/hashCode for TowerGroupKind.WithDepth --- .../fir/resolve/calls/tower/TowerGroup.kt | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt index bf091f7276f..0736129aa58 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/tower/TowerGroup.kt @@ -5,8 +5,24 @@ package org.jetbrains.kotlin.fir.resolve.calls.tower -sealed class TowerGroupKind(private val index: Int) : Comparable { - abstract class WithDepth(index: Int, val depth: Int) : TowerGroupKind(index) +sealed class TowerGroupKind(protected val index: Int) : Comparable { + abstract class WithDepth(index: Int, val depth: Int) : TowerGroupKind(index) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as WithDepth + + if (index != other.index) return false + if (depth != other.depth) return false + + return true + } + + override fun hashCode(): Int { + return 31 * depth + index + } + } object Start : TowerGroupKind(Integer.MIN_VALUE)