Skip to content

Commit 2093b93

Browse files
committed
Generalize TokenData#isOperator
1 parent 53928a9 commit 2093b93

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ object Scanners {
8888
def isAfterLineEnd: Boolean = lineOffset >= 0
8989

9090
def isOperator =
91-
token == IDENTIFIER && isOperatorPart(name(name.length - 1))
91+
token == BACKQUOTED_IDENT
92+
|| token == IDENTIFIER && isOperatorPart(name(name.length - 1))
9293

9394
def isArrow =
9495
token == ARROW || token == CTXARROW
@@ -370,8 +371,7 @@ object Scanners {
370371
*/
371372
def isLeadingInfixOperator(inConditional: Boolean = true) =
372373
allowLeadingInfixOperators
373-
&& ( token == BACKQUOTED_IDENT
374-
|| token == IDENTIFIER && isOperatorPart(name(name.length - 1)))
374+
&& isOperator
375375
&& (isWhitespace(ch) || ch == LF)
376376
&& !pastBlankLine
377377
&& {
@@ -389,7 +389,7 @@ object Scanners {
389389
// leading infix operator.
390390
def assumeStartsExpr(lexeme: TokenData) =
391391
canStartExprTokens.contains(lexeme.token)
392-
&& (token != BACKQUOTED_IDENT || !lexeme.isOperator || nme.raw.isUnary(lexeme.name))
392+
&& (!lexeme.isOperator || nme.raw.isUnary(lexeme.name))
393393
val lookahead = LookaheadScanner()
394394
lookahead.allowLeadingInfixOperators = false
395395
// force a NEWLINE a after current token if it is on its own line

0 commit comments

Comments
 (0)