From 9bdd5e47ac93f9253de8fae10932c48fe6e4a317 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 30 Mar 2020 15:50:16 +0300 Subject: [PATCH] [FIR] Fix equality for cfg nodes --- .../jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt | 2 +- .../kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt index 6c4884208f1..c5d064b3f14 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraph.kt @@ -102,7 +102,7 @@ sealed class CFGNode(val owner: ControlFlowGraph, val level: final override fun equals(other: Any?): Boolean { if (other !is CFGNode<*>) return false - return this.id == other.id + return this === other } final override fun hashCode(): Int { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt index 00cf41bf9cf..300928a2005 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/cfg/ControlFlowGraphBuilder.kt @@ -15,6 +15,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.types.isNothing +import kotlin.random.Random class ControlFlowGraphBuilder { private val graphs: Stack = stackOf(ControlFlowGraph(null, "", ControlFlowGraph.Kind.TopLevel)) @@ -60,7 +61,7 @@ class ControlFlowGraphBuilder { var levelCounter: Int = 0 private set - private var idCounter: Int = 0 + private var idCounter: Int = Random.nextInt() private val shouldPassFlowFromInplaceLambda: Stack = stackOf(true) fun createId(): Int = idCounter++