Skip to content

Commit 957c8be

Browse files
committed
Promote to overloaded accept
1 parent 53a472e commit 957c8be

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,13 @@ object Parsers {
328328
if in.token == token then in.nextToken()
329329
offset
330330

331+
def accept(token: Int, help: String): Int =
332+
val offset = in.offset
333+
if in.token != token then
334+
syntaxErrorOrIncomplete(ExpectedTokenButFound(token, in.token, suffix = help))
335+
if in.token == token then in.nextToken()
336+
offset
337+
331338
def accept(name: Name): Int = {
332339
val offset = in.offset
333340
if !isIdent(name) then
@@ -4090,7 +4097,7 @@ object Parsers {
40904097
lhs match
40914098
case Ident(name) :: Nil if name.endsWith(":") =>
40924099
val help = i"; identifier ends in colon, did you mean `${name.toSimpleName.dropRight(1)}`: in backticks?"
4093-
syntaxErrorOrIncomplete(ExpectedTokenButFound(EQUALS, in.token, suffix = help))
4100+
accept(EQUALS, help)
40944101
case _ => accept(EQUALS)
40954102
else
40964103
accept(EQUALS)
@@ -4193,7 +4200,7 @@ object Parsers {
41934200
else EmptyTree
41944201
else if in.token == IDENTIFIER && paramss.isEmpty && name.endsWith(":") then
41954202
val help = i"; identifier ends in colon, did you mean `${name.toSimpleName.dropRight(1)}`: in backticks?"
4196-
syntaxErrorOrIncomplete(ExpectedTokenButFound(EQUALS, in.token, suffix = help))
4203+
accept(EQUALS, help)
41974204
EmptyTree
41984205
else
41994206
if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)

0 commit comments

Comments
 (0)