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