Skip to content

Commit 7694a5c

Browse files
committed
Avoid shadowing of name 'name'
1 parent ad5c714 commit 7694a5c

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

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

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -242,24 +242,17 @@ object Scanners {
242242
/** A buffer for comments */
243243
private val commentBuf = CharBuffer()
244244

245-
private def handleMigration(keyword: Token): Token =
246-
if scala3keywords.contains(keyword) && migrateTo3 then treatAsIdent()
247-
else keyword
248-
249-
private def treatAsIdent(): Token =
250-
val name0 = name // don't capture the `name` var in the message closure, it may be null later
251-
report.errorOrMigrationWarning(
252-
i"$name0 is now a keyword, write `$name0` instead of $name0 to keep it as an identifier",
253-
sourcePos())
254-
patch(source, Span(offset), "`")
255-
patch(source, Span(offset + name.length), "`")
256-
IDENTIFIER
257-
258-
def toToken(name: SimpleName): Token = {
259-
val idx = name.start
245+
def toToken(identifier: SimpleName): Token =
246+
def handleMigration(keyword: Token): Token =
247+
if scala3keywords.contains(keyword) && migrateTo3 then
248+
report.errorOrMigrationWarning(i"$identifier is now a keyword, write `$identifier` instead of $identifier to keep it as an identifier", sourcePos())
249+
patch(source, Span(offset), "`")
250+
patch(source, Span(offset + identifier.length), "`")
251+
IDENTIFIER
252+
else keyword
253+
val idx = identifier.start
260254
if (idx >= 0 && idx <= lastKeywordStart) handleMigration(kwArray(idx))
261255
else IDENTIFIER
262-
}
263256

264257
def newTokenData: TokenData = new TokenData {}
265258

0 commit comments

Comments
 (0)