From d20e5ce673ff0e35373bfed370565e1e765bcbb5 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Fri, 20 Jul 2018 16:27:08 +0300 Subject: [PATCH] Cache hashCode for DataFlowValue in another field It's necessary because DataFlowValue instances are commonly used as keys in maps #KT-24657 Fixed --- .../resolve/calls/smartcasts/DataFlowValue.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt index 74aa99fe02c..ac3c8350d9d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/smartcasts/DataFlowValue.kt @@ -90,7 +90,18 @@ class DataFlowValue( override fun toString() = "$kind $identifierInfo $immanentNullability" - override fun hashCode() = type.hashCode() + 31 * identifierInfo.hashCode() + private var hashCode = 0 + + override fun hashCode(): Int { + var hashCode = hashCode + + if (hashCode == 0) { + hashCode = type.hashCode() + 31 * identifierInfo.hashCode() + this.hashCode = hashCode + } + + return hashCode + } companion object {