Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d394833

Browse files
Promote to overloaded accept
1 parent ebd56e4 commit d394833

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
@@ -4012,7 +4019,7 @@ object Parsers {
40124019
lhs match
40134020
case Ident(name) :: Nil if name.endsWith(":") =>
40144021
val help = i"; identifier ends in colon, did you mean `${name.toSimpleName.dropRight(1)}`: in backticks?"
4015-
syntaxErrorOrIncomplete(ExpectedTokenButFound(EQUALS, in.token, suffix =help))
4022+
accept(EQUALS, help)
40164023
case _ => accept(EQUALS)
40174024
else
40184025
accept(EQUALS)
@@ -4115,7 +4122,7 @@ object Parsers {
41154122
else EmptyTree
41164123
else if in.token == IDENTIFIER && paramss.isEmpty && name.endsWith(":") then
41174124
val help = i"; identifier ends in colon, did you mean `${name.toSimpleName.dropRight(1)}`: in backticks?"
4118-
syntaxErrorOrIncomplete(ExpectedTokenButFound(EQUALS, in.token, suffix =help))
4125+
accept(EQUALS, help)
41194126
EmptyTree
41204127
else
41214128
if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /