@@ -166,22 +166,24 @@ object Parsers {
166
166
def isSimpleLiteral : Boolean = simpleLiteralTokens contains in.token
167
167
def isLiteral : Boolean = literalTokens contains in.token
168
168
def isNumericLit : Boolean = numericLitTokens contains in.token
169
- def isModifier : Boolean = modifierTokens.contains(in.token) || isIdent(nme.INLINEkw )
170
169
def isBindingIntro : Boolean = canStartBindingTokens contains in.token
171
170
def isTemplateIntro : Boolean = templateIntroTokens contains in.token
172
171
def isDclIntro : Boolean = dclIntroTokens contains in.token
173
172
def isStatSeqEnd : Boolean = in.token == RBRACE || in.token == EOF
174
173
def mustStartStat : Boolean = mustStartStatTokens contains in.token
175
174
175
+ /** Is current token a hard or soft modifier (in modifier position or not)? */
176
+ def isModifier : Boolean = modifierTokens.contains(in.token) || in.isSoftModifier
177
+
176
178
def isExprIntro : Boolean =
177
- ( canStartExpressionTokens ` contains` in.token) &&
178
- ( ! isIdent(nme. INLINEkw ) || lookaheadIn(canStartExpressionTokens))
179
+ canStartExpressionTokens. contains( in.token) &&
180
+ ! in.isSoftModifierInModifierPosition
179
181
180
182
def isDefIntro (allowedMods : BitSet ): Boolean =
181
183
in.token == AT ||
182
184
(defIntroTokens `contains` in.token) ||
183
185
(allowedMods `contains` in.token) ||
184
- isIdent(nme. INLINEkw ) && lookaheadIn( BitSet ( AT ) | defIntroTokens | allowedMods)
186
+ in.isSoftModifierInModifierPosition
185
187
186
188
def isStatSep : Boolean =
187
189
in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
@@ -455,14 +457,6 @@ object Parsers {
455
457
456
458
def commaSeparated [T ](part : () => T ): List [T ] = tokenSeparated(COMMA , part)
457
459
458
- /** Is the token following the current one in `tokens`? */
459
- def lookaheadIn (tokens : BitSet ): Boolean = {
460
- val lookahead = in.lookaheadScanner
461
- do lookahead.nextToken()
462
- while (lookahead.token == NEWLINE || lookahead.token == NEWLINES )
463
- tokens.contains(lookahead.token)
464
- }
465
-
466
460
/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
467
461
468
462
var opStack : List [OpInfo ] = Nil
@@ -841,7 +835,7 @@ object Parsers {
841
835
842
836
/** Is current ident a `*`, and is it followed by a `)` or `,`? */
843
837
def isPostfixStar : Boolean =
844
- in.name == nme.raw.STAR && lookaheadIn(BitSet (RPAREN , COMMA ))
838
+ in.name == nme.raw.STAR && in. lookaheadIn(BitSet (RPAREN , COMMA ))
845
839
846
840
def infixTypeRest (t : Tree ): Tree =
847
841
infixOps(t, canStartTypeTokens, refinedType, isType = true , isOperator = ! isPostfixStar)
@@ -899,7 +893,7 @@ object Parsers {
899
893
val start = in.skipToken()
900
894
typeBounds().withPos(Position (start, in.lastOffset, start))
901
895
}
902
- else if (isIdent(nme.raw.TILDE ) && lookaheadIn(BitSet (IDENTIFIER , BACKQUOTED_IDENT )))
896
+ else if (isIdent(nme.raw.TILDE ) && in. lookaheadIn(BitSet (IDENTIFIER , BACKQUOTED_IDENT )))
903
897
atPos(in.offset) { PrefixOp (typeIdent(), path(thisOK = true )) }
904
898
else path(thisOK = false , handleSingletonType) match {
905
899
case r @ SingletonTypeTree (_) => r
@@ -1744,8 +1738,11 @@ object Parsers {
1744
1738
case PRIVATE => Mod .Private ()
1745
1739
case PROTECTED => Mod .Protected ()
1746
1740
case SEALED => Mod .Sealed ()
1747
- case OPAQUE => Mod .Opaque ()
1748
- case IDENTIFIER if name == nme.INLINEkw => Mod .Inline ()
1741
+ case IDENTIFIER =>
1742
+ name match {
1743
+ case nme.`inline` => Mod .Inline ()
1744
+ case nme.`opaque` => Mod .Opaque ()
1745
+ }
1749
1746
}
1750
1747
1751
1748
/** Drop `private' modifier when followed by a qualifier.
@@ -1816,7 +1813,8 @@ object Parsers {
1816
1813
@ tailrec
1817
1814
def loop (mods : Modifiers ): Modifiers = {
1818
1815
if (allowed.contains(in.token) ||
1819
- isIdent(nme.INLINEkw ) && localModifierTokens.subsetOf(allowed)) {
1816
+ in.isSoftModifier &&
1817
+ localModifierTokens.subsetOf(allowed)) { // soft modifiers are admissible everywhere local modifiers are
1820
1818
val isAccessMod = accessModifierTokens contains in.token
1821
1819
val mods1 = addModifier(mods)
1822
1820
loop(if (isAccessMod) accessQualifierOpt(mods1) else mods1)
@@ -1957,7 +1955,7 @@ object Parsers {
1957
1955
}
1958
1956
}
1959
1957
else {
1960
- if (isIdent(nme.INLINEkw )) mods = addModifier(mods)
1958
+ if (isIdent(nme.`inline` )) mods = addModifier(mods)
1961
1959
mods = atPos(start) { mods | Param }
1962
1960
}
1963
1961
atPos(start, nameStart) {
@@ -2616,7 +2614,7 @@ object Parsers {
2616
2614
if (in.token == IMPLICIT || in.token == ERASED ) {
2617
2615
val start = in.offset
2618
2616
var imods = modifiers(funArgMods)
2619
- if (isBindingIntro && ! isIdent(nme.INLINEkw ))
2617
+ if (isBindingIntro && ! isIdent(nme.`inline` ))
2620
2618
stats += implicitClosure(start, Location .InBlock , imods)
2621
2619
else
2622
2620
stats +++= localDef(start, imods)
0 commit comments