Fixed bug

This commit is contained in:
Valentin Kipyatkov
2016-08-11 20:58:17 +03:00
parent bdd4363802
commit dde397f34d
@@ -93,8 +93,6 @@ fun match(loop: KtForExpression, useLazySequence: Boolean): MatchResult? {
if (match != null) { if (match != null) {
if (!inputVariableUsed && match.allTransformations.any { it.shouldUseInputVariable }) return null if (!inputVariableUsed && match.allTransformations.any { it.shouldUseInputVariable }) return null
state.previousTransformations += match.sequenceTransformations
when (match) { when (match) {
is TransformationMatch.Sequence -> { is TransformationMatch.Sequence -> {
// check that old input variable is not needed anymore // 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 if (countAfter != countBefore) continue@MatchersLoop // some embedded break or continue in the matched part
} }
state.previousTransformations += match.sequenceTransformations
state = newState state = newState
continue@MatchLoop continue@MatchLoop
} }
@@ -120,6 +119,8 @@ fun match(loop: KtForExpression, useLazySequence: Boolean): MatchResult? {
is TransformationMatch.Result -> { is TransformationMatch.Result -> {
if (restContainsEmbeddedBreakOrContinue && !matcher.embeddedBreakOrContinuePossible) continue@MatchersLoop if (restContainsEmbeddedBreakOrContinue && !matcher.embeddedBreakOrContinuePossible) continue@MatchersLoop
state.previousTransformations += match.sequenceTransformations
var result = TransformationMatch.Result(match.resultTransformation, state.previousTransformations) var result = TransformationMatch.Result(match.resultTransformation, state.previousTransformations)
result = mergeTransformations(result) result = mergeTransformations(result)