diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt index 72043f4a3b1..c0013505149 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/RedundantGotoMethodTransformer.kt @@ -34,18 +34,14 @@ class RedundantGotoMethodTransformer : MethodTransformer() { val currentLabels = hashSetOf() for (insn in insns) { - if (insn.isMeaningful) { - if (insn.opcode == Opcodes.GOTO && (insn as JumpInsnNode).label in currentLabels) { + when { + insn is LabelNode -> + currentLabels.add(insn) + insn.opcode == Opcodes.GOTO && + (insn as JumpInsnNode).label in currentLabels -> insnsToRemove.add(insn) - } - else { + insn.isMeaningful -> currentLabels.clear() - } - continue - } - - if (insn is LabelNode) { - currentLabels.add(insn) } }