@@ -581,11 +581,6 @@ object Parsers {
581581 */
582582 var possibleColonOffset : Int = - 1
583583
584- /** A list of pending patches, to be issued if we can rewrite all enclosing braces to
585- * indentation regions.
586- */
587- var pendingPatches : List [() => Unit ] = Nil
588-
589584 def testChar (idx : Int , p : Char => Boolean ): Boolean = {
590585 val txt = source.content
591586 idx < txt.length && p(txt(idx))
@@ -607,10 +602,7 @@ object Parsers {
607602 /** Parse indentation region `body` and rewrite it to be in braces instead */
608603 def indentedToBraces [T ](body : => T ): T = {
609604 val enclRegion = in.currentRegion.enclosing
610- def indentWidth = enclRegion match {
611- case Indented (w, _, _, _) => w
612- case _ => IndentWidth .Zero
613- }
605+ def indentWidth = enclRegion.indentWidth
614606 val followsColon = testChar(in.lastOffset - 1 , ':' )
615607 val startOpening =
616608 if (followsColon)
@@ -706,7 +698,6 @@ object Parsers {
706698 val colonRequired = possibleColonOffset == in.lastOffset
707699 val (startOpening, endOpening) = startingElimRegion(colonRequired)
708700 val isOutermost = in.currentRegion.isOutermost
709- val savedPending = pendingPatches
710701 def allBraces (r : Region ): Boolean = r match {
711702 case r : InBraces => allBraces(r.enclosing)
712703 case _ => r.isOutermost
@@ -728,17 +719,9 @@ object Parsers {
728719 else if (testChar(startOpening - 1 , Chars .isOperatorPart(_))) " :"
729720 else " :"
730721 val (startClosing, endClosing) = closingElimRegion()
731- val applyPatch = () => {
732- patch(source, Span (startOpening, endOpening), openingPatchStr)
733- patch(source, Span (startClosing, endClosing), " " )
734- }
735- pendingPatches = applyPatch :: pendingPatches
736- if (isOutermost) {
737- pendingPatches.reverse.foreach(_())
738- pendingPatches = Nil
739- }
722+ patch(source, Span (startOpening, endOpening), openingPatchStr)
723+ patch(source, Span (startClosing, endClosing), " " )
740724 }
741- else pendingPatches = savedPending // can't rewrite, cancel all nested patches.
742725 t
743726 }
744727
@@ -1175,7 +1158,7 @@ object Parsers {
11751158 }
11761159
11771160 def indentRegion [T ](tag : EndMarkerTag )(op : => T ): T = {
1178- val iw = in.currentIndentWidth
1161+ val iw = in.currentRegion.indentWidth
11791162 val t = op
11801163 in.consumeEndMarker(tag, iw)
11811164 t
@@ -3370,9 +3353,8 @@ object Parsers {
33703353 case _ => false
33713354 }
33723355
3373- def givenArgs (t : Tree ): Tree = {
3356+ def givenArgs (t : Tree ): Tree =
33743357 if (in.token == GIVEN ) givenArgs(applyGiven(t, prefixExpr)) else t
3375- }
33763358
33773359 if (in.token == LPAREN )
33783360 inParens {
0 commit comments