Skip to content

Commit 53928a9

Browse files
committed
Use isArrow utility method in Parser
1 parent e80a192 commit 53928a9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,11 @@ object Parsers {
198198
in.token match {
199199
case USCORE => true
200200
case IDENTIFIER | BACKQUOTED_IDENT =>
201-
val nxt = in.lookahead.token
202-
nxt == ARROW || nxt == CTXARROW
201+
in.lookahead.isArrow
203202
case LPAREN =>
204203
val lookahead = in.LookaheadScanner()
205204
lookahead.skipParens()
206-
lookahead.token == ARROW || lookahead.token == CTXARROW
205+
lookahead.isArrow
207206
case _ => false
208207
}
209208
} && !in.isSoftModifierInModifierPosition
@@ -1392,7 +1391,7 @@ object Parsers {
13921391
funArgTypesRest(t, funArgType)
13931392
}
13941393
accept(RPAREN)
1395-
if isValParamList || in.token == ARROW || in.token == CTXARROW then
1394+
if isValParamList || in.isArrow then
13961395
functionRest(ts)
13971396
else {
13981397
val ts1 =
@@ -1881,15 +1880,13 @@ object Parsers {
18811880
finally placeholderParams = saved
18821881

18831882
val t = expr1(location)
1884-
if (in.token == ARROW || in.token == CTXARROW) {
1883+
if in.isArrow then
18851884
placeholderParams = Nil // don't interpret `_' to the left of `=>` as placeholder
18861885
val paramMods = if in.token == CTXARROW then Modifiers(Given) else EmptyModifiers
18871886
wrapPlaceholders(closureRest(start, location, convertToParams(t, paramMods)))
1888-
}
1889-
else if (isWildcard(t)) {
1887+
else if isWildcard(t) then
18901888
placeholderParams = placeholderParams ::: saved
18911889
t
1892-
}
18931890
else wrapPlaceholders(t)
18941891
}
18951892
}
@@ -2262,7 +2259,8 @@ object Parsers {
22622259
val app = atSpan(startOffset(t), in.offset) { mkApply(t, argumentExprs()) }
22632260
simpleExprRest(app, canApply = true)
22642261
case USCORE =>
2265-
atSpan(startOffset(t), in.skipToken()) { PostfixOp(t, Ident(nme.WILDCARD)) }
2262+
if in.lookahead.isArrow then ???
2263+
else atSpan(startOffset(t), in.skipToken()) { PostfixOp(t, Ident(nme.WILDCARD)) }
22662264
case _ =>
22672265
t
22682266
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ object Scanners {
8989

9090
def isOperator =
9191
token == IDENTIFIER && isOperatorPart(name(name.length - 1))
92+
93+
def isArrow =
94+
token == ARROW || token == CTXARROW
9295
}
9396

9497
abstract class ScannerCommon(source: SourceFile)(using Context) extends CharArrayReader with TokenData {

0 commit comments

Comments
 (0)