diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/IntroduceIndexMatcher.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/IntroduceIndexMatcher.kt index c7ba4535816..3e8434b2610 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/IntroduceIndexMatcher.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/sequence/IntroduceIndexMatcher.kt @@ -69,8 +69,8 @@ object IntroduceIndexMatcher : TransformationMatcher { val pseudocode = state.pseudocodeProvider() val firstStatement = state.statements.first() - val firstInstruction = pseudocode.instructionForElement(firstStatement)!! - val incrementInstruction = pseudocode.instructionForElement(incrementExpression)!! + val firstInstruction = pseudocode.instructionForElement(firstStatement) ?: return null + val incrementInstruction = pseudocode.instructionForElement(incrementExpression) ?: return null if (!isAlwaysReachedOrExitedLoop(firstInstruction, incrementInstruction, state.outerLoop, state.innerLoop)) return null val variableDescriptor = variable.unsafeResolveToDescriptor() as VariableDescriptor