Make code in IntroduceIndexMatcher safer

EA-101119 Fixed
This commit is contained in:
Mikhail Glukhikh
2018-08-15 17:47:29 +03:00
parent d67dea4619
commit 57153cc2fc
@@ -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