diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt index 1c3cc009daa..c4856c5f84f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/PseudocodeImpl.kt @@ -58,8 +58,12 @@ class PseudocodeImpl(override val correspondingElement: KtElement) : Pseudocode } fun resolveToInstruction(): Instruction { - assert(targetInstructionIndex != null) - return mutableInstructionList[targetInstructionIndex!!] + val index = targetInstructionIndex + if (index == null || index >= mutableInstructionList.size) { + error("resolveToInstruction: incorrect index $index for label $name " + + "in subroutine ${correspondingElement.text} with instructions $mutableInstructionList") + } + return mutableInstructionList[index] } fun copy(newLabelIndex: Int): PseudocodeLabel {