@@ -662,7 +662,7 @@ object Scanners {
662662 true
663663 else token == COLONfollow && (inTemplate || fewerBracesEnabled)
664664 if enabled then
665- lookAhead ()
665+ peekAhead ()
666666 val atEOL = isAfterLineEnd || token == EOF
667667 reset()
668668 if atEOL then token = COLONeol
@@ -690,15 +690,14 @@ object Scanners {
690690 insert(OUTDENT , offset)
691691 case _ =>
692692
693- def lookAhead () =
693+ def peekAhead () =
694694 prev.copyFrom(this )
695695 getNextToken(token)
696696 if token == END && ! isEndMarker then token = IDENTIFIER
697697
698- def reset () = {
698+ def reset () =
699699 next.copyFrom(this )
700700 this .copyFrom(prev)
701- }
702701
703702 def closeIndented () = currentRegion match
704703 case r : Indented if ! r.isOutermost => insert(OUTDENT , offset)
@@ -717,12 +716,12 @@ object Scanners {
717716 }
718717 (token : @ switch) match {
719718 case CASE =>
720- lookAhead ()
719+ peekAhead ()
721720 if (token == CLASS ) fuse(CASECLASS )
722721 else if (token == OBJECT ) fuse(CASEOBJECT )
723722 else reset()
724723 case SEMI =>
725- lookAhead ()
724+ peekAhead ()
726725 if (token != ELSE ) reset()
727726 case COMMA =>
728727 def isEnclosedInParens (r : Region ): Boolean = r match
@@ -733,7 +732,7 @@ object Scanners {
733732 case r : Indented if isEnclosedInParens(r.outer) =>
734733 insert(OUTDENT , offset)
735734 case _ =>
736- lookAhead ()
735+ peekAhead ()
737736 if isAfterLineEnd
738737 && currentRegion.commasExpected
739738 && (token == RPAREN || token == RBRACKET || token == RBRACE || token == OUTDENT )
@@ -1083,11 +1082,14 @@ object Scanners {
10831082 * The token is computed via fetchToken, so complex two word
10841083 * tokens such as CASECLASS are not recognized.
10851084 * Newlines and indent/unindent tokens are skipped.
1086- *
1085+ * Restriction: `lookahead` is illegal if the current token is INTERPOLATIONID
10871086 */
1088- def lookahead : TokenData =
1087+ def lookahead : TokenData =
10891088 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()
10911093 reset()
10921094 next
10931095
0 commit comments