From 6980d28eb0550b703af1b4879015c7dafad9f9af Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Apr 2016 15:10:26 +0300 Subject: [PATCH] Refactoring: ControlFlowInstructionsGenerator.handleJumpInsideTryFinally --- .../ControlFlowInstructionsGenerator.kt | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt index 82bd26f235e..8ce6305f6e5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/ControlFlowInstructionsGenerator.kt @@ -200,18 +200,15 @@ class ControlFlowInstructionsGenerator : ControlFlowBuilderAdapter() { private fun handleJumpInsideTryFinally(jumpTarget: Label) { val finallyBlocks = ArrayList() - for (i in allBlocks.indices.reversed()) { - val blockInfo = allBlocks[i] - if (blockInfo is BreakableBlockInfo) { - if (blockInfo.referablePoints.contains(jumpTarget) || jumpTarget === error) { - for (j in finallyBlocks.indices) { - finallyBlocks[j].generateFinallyBlock() + for (blockInfo in allBlocks.asReversed()) { + when (blockInfo) { + is BreakableBlockInfo -> if (blockInfo.referablePoints.contains(jumpTarget) || jumpTarget === error) { + for (finallyBlockInfo in finallyBlocks) { + finallyBlockInfo.generateFinallyBlock() } - break + return } - } - else if (blockInfo is TryFinallyBlockInfo) { - finallyBlocks.add(blockInfo) + is TryFinallyBlockInfo -> finallyBlocks.add(blockInfo) } } }