@@ -662,7 +662,7 @@ object Scanners {
662
662
true
663
663
else token == COLONfollow && (inTemplate || fewerBracesEnabled)
664
664
if enabled then
665
- lookAhead ()
665
+ peekAhead ()
666
666
val atEOL = isAfterLineEnd || token == EOF
667
667
reset()
668
668
if atEOL then token = COLONeol
@@ -690,15 +690,14 @@ object Scanners {
690
690
insert(OUTDENT , offset)
691
691
case _ =>
692
692
693
- def lookAhead () =
693
+ def peekAhead () =
694
694
prev.copyFrom(this )
695
695
getNextToken(token)
696
696
if token == END && ! isEndMarker then token = IDENTIFIER
697
697
698
- def reset () = {
698
+ def reset () =
699
699
next.copyFrom(this )
700
700
this .copyFrom(prev)
701
- }
702
701
703
702
def closeIndented () = currentRegion match
704
703
case r : Indented if ! r.isOutermost => insert(OUTDENT , offset)
@@ -717,12 +716,12 @@ object Scanners {
717
716
}
718
717
(token : @ switch) match {
719
718
case CASE =>
720
- lookAhead ()
719
+ peekAhead ()
721
720
if (token == CLASS ) fuse(CASECLASS )
722
721
else if (token == OBJECT ) fuse(CASEOBJECT )
723
722
else reset()
724
723
case SEMI =>
725
- lookAhead ()
724
+ peekAhead ()
726
725
if (token != ELSE ) reset()
727
726
case COMMA =>
728
727
def isEnclosedInParens (r : Region ): Boolean = r match
@@ -733,7 +732,7 @@ object Scanners {
733
732
case r : Indented if isEnclosedInParens(r.outer) =>
734
733
insert(OUTDENT , offset)
735
734
case _ =>
736
- lookAhead ()
735
+ peekAhead ()
737
736
if isAfterLineEnd
738
737
&& currentRegion.commasExpected
739
738
&& (token == RPAREN || token == RBRACKET || token == RBRACE || token == OUTDENT )
@@ -1083,11 +1082,14 @@ object Scanners {
1083
1082
* The token is computed via fetchToken, so complex two word
1084
1083
* tokens such as CASECLASS are not recognized.
1085
1084
* Newlines and indent/unindent tokens are skipped.
1086
- *
1085
+ * Restriction: `lookahead` is illegal if the current token is INTERPOLATIONID
1087
1086
*/
1088
- def lookahead : TokenData =
1087
+ def lookahead : TokenData =
1089
1088
if next.token == EMPTY then
1090
- lookAhead()
1089
+ assert(token != INTERPOLATIONID )
1090
+ // INTERPOLATONIDs are followed by a string literal, which can set next
1091
+ // in peekAhead(). In that case, the following reset() would forget that token.
1092
+ peekAhead()
1091
1093
reset()
1092
1094
next
1093
1095
0 commit comments