From dde397f34d7353bc932ca2d51046c5ca81bb8461 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 11 Aug 2016 20:58:17 +0300 Subject: [PATCH] Fixed bug --- .../idea/intentions/loopToCallChain/matchAndConvert.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt index 172a9f77124..bbd358fa661 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/loopToCallChain/matchAndConvert.kt @@ -93,8 +93,6 @@ fun match(loop: KtForExpression, useLazySequence: Boolean): MatchResult? { if (match != null) { if (!inputVariableUsed && match.allTransformations.any { it.shouldUseInputVariable }) return null - state.previousTransformations += match.sequenceTransformations - when (match) { is TransformationMatch.Sequence -> { // check that old input variable is not needed anymore @@ -113,6 +111,7 @@ fun match(loop: KtForExpression, useLazySequence: Boolean): MatchResult? { if (countAfter != countBefore) continue@MatchersLoop // some embedded break or continue in the matched part } + state.previousTransformations += match.sequenceTransformations state = newState continue@MatchLoop } @@ -120,6 +119,8 @@ fun match(loop: KtForExpression, useLazySequence: Boolean): MatchResult? { is TransformationMatch.Result -> { if (restContainsEmbeddedBreakOrContinue && !matcher.embeddedBreakOrContinuePossible) continue@MatchersLoop + state.previousTransformations += match.sequenceTransformations + var result = TransformationMatch.Result(match.resultTransformation, state.previousTransformations) result = mergeTransformations(result)