Skip to content

Commit 0605327

Browse files
committed
Allow rewritings under constructs that could not be rewritten
1 parent 9e9c27e commit 0605327

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+3-18
Original file line numberDiff line numberDiff line change
@@ -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))
@@ -703,7 +698,6 @@ object Parsers {
703698
val colonRequired = possibleColonOffset == in.lastOffset
704699
val (startOpening, endOpening) = startingElimRegion(colonRequired)
705700
val isOutermost = in.currentRegion.isOutermost
706-
val savedPending = pendingPatches
707701
def allBraces(r: Region): Boolean = r match {
708702
case r: InBraces => allBraces(r.enclosing)
709703
case _ => r.isOutermost
@@ -725,17 +719,9 @@ object Parsers {
725719
else if (testChar(startOpening - 1, Chars.isOperatorPart(_))) " :"
726720
else ":"
727721
val (startClosing, endClosing) = closingElimRegion()
728-
val applyPatch = () => {
729-
patch(source, Span(startOpening, endOpening), openingPatchStr)
730-
patch(source, Span(startClosing, endClosing), "")
731-
}
732-
pendingPatches = applyPatch :: pendingPatches
733-
if (isOutermost) {
734-
pendingPatches.reverse.foreach(_())
735-
pendingPatches = Nil
736-
}
722+
patch(source, Span(startOpening, endOpening), openingPatchStr)
723+
patch(source, Span(startClosing, endClosing), "")
737724
}
738-
else pendingPatches = savedPending // can't rewrite, cancel all nested patches.
739725
t
740726
}
741727

@@ -3367,9 +3353,8 @@ object Parsers {
33673353
case _ => false
33683354
}
33693355

3370-
def givenArgs(t: Tree): Tree = {
3356+
def givenArgs(t: Tree): Tree =
33713357
if (in.token == GIVEN) givenArgs(applyGiven(t, prefixExpr)) else t
3372-
}
33733358

33743359
if (in.token == LPAREN)
33753360
inParens {

0 commit comments

Comments
 (0)