From 57153cc2fcccac832f70d846709d6b6d734824bd Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 15 Aug 2018 17:47:29 +0300 Subject: [PATCH] Make code in IntroduceIndexMatcher safer EA-101119 Fixed --- .../loopToCallChain/sequence/IntroduceIndexMatcher.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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