Skip to content

Commit 1f47f64

Browse files
committed
Distinguish simple finishNamed from fiddly finishNamedToken
1 parent 59f81dd commit 1f47f64

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

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

+8-5
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,13 @@ object Scanners {
135135
*/
136136
protected def putChar(c: Char): Unit = litBuf.append(c)
137137

138-
/** Clear buffer and set name and token
139-
* If `target` is different from `this`, don't treat identifiers as end tokens
138+
/** Finish an IDENTIFIER with `this.name`. */
139+
inline def finishNamed(): Unit = finishNamedToken(IDENTIFIER, this)
140+
141+
/** Clear buffer and set name and token.
142+
* If `target` is different from `this`, don't treat identifiers as end tokens.
140143
*/
141-
def finishNamed(idtoken: Token = IDENTIFIER, target: TokenData = this): Unit =
144+
def finishNamedToken(idtoken: Token, target: TokenData): Unit =
142145
target.name = termName(litBuf.chars, 0, litBuf.length)
143146
litBuf.clear()
144147
target.token = idtoken
@@ -996,7 +999,7 @@ object Scanners {
996999
getLitChars('`')
9971000
if (ch == '`') {
9981001
nextChar()
999-
finishNamed(BACKQUOTED_IDENT)
1002+
finishNamedToken(BACKQUOTED_IDENT, target = this)
10001003
if (name.length == 0)
10011004
error("empty quoted identifier")
10021005
else if (name == nme.WILDCARD)
@@ -1162,7 +1165,7 @@ object Scanners {
11621165
nextRawChar()
11631166
ch != SU && Character.isUnicodeIdentifierPart(ch)
11641167
do ()
1165-
finishNamed(target = next)
1168+
finishNamedToken(IDENTIFIER, target = next)
11661169
}
11671170
else
11681171
error("invalid string interpolation: `$$`, `$\"`, `$`ident or `$`BlockExpr expected")

0 commit comments

Comments
 (0)