@@ -166,22 +166,27 @@ object Parsers {
166166 def isSimpleLiteral : Boolean = simpleLiteralTokens contains in.token
167167 def isLiteral : Boolean = literalTokens contains in.token
168168 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
171169 def isTemplateIntro : Boolean = templateIntroTokens contains in.token
172170 def isDclIntro : Boolean = dclIntroTokens contains in.token
173171 def isStatSeqEnd : Boolean = in.token == RBRACE || in.token == EOF
174172 def mustStartStat : Boolean = mustStartStatTokens contains in.token
175173
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+
176181 def isExprIntro : Boolean =
177- ( canStartExpressionTokens ` contains` in.token) &&
178- ( ! isIdent(nme. INLINEkw ) || lookaheadIn(canStartExpressionTokens))
182+ canStartExpressionTokens. contains( in.token) &&
183+ ! in.isSoftModifierInModifierPosition
179184
180185 def isDefIntro (allowedMods : BitSet ): Boolean =
181186 in.token == AT ||
182187 (defIntroTokens `contains` in.token) ||
183188 (allowedMods `contains` in.token) ||
184- isIdent(nme. INLINEkw ) && lookaheadIn( BitSet ( AT ) | defIntroTokens | allowedMods)
189+ in.isSoftModifierInModifierPosition
185190
186191 def isStatSep : Boolean =
187192 in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
@@ -455,14 +460,6 @@ object Parsers {
455460
456461 def commaSeparated [T ](part : () => T ): List [T ] = tokenSeparated(COMMA , part)
457462
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-
466463/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
467464
468465 var opStack : List [OpInfo ] = Nil
@@ -841,7 +838,7 @@ object Parsers {
841838
842839 /** Is current ident a `*`, and is it followed by a `)` or `,`? */
843840 def isPostfixStar : Boolean =
844- in.name == nme.raw.STAR && lookaheadIn(BitSet (RPAREN , COMMA ))
841+ in.name == nme.raw.STAR && in. lookaheadIn(BitSet (RPAREN , COMMA ))
845842
846843 def infixTypeRest (t : Tree ): Tree =
847844 infixOps(t, canStartTypeTokens, refinedType, isType = true , isOperator = ! isPostfixStar)
@@ -899,7 +896,7 @@ object Parsers {
899896 val start = in.skipToken()
900897 typeBounds().withPos(Position (start, in.lastOffset, start))
901898 }
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 )))
903900 atPos(in.offset) { PrefixOp (typeIdent(), path(thisOK = true )) }
904901 else path(thisOK = false , handleSingletonType) match {
905902 case r @ SingletonTypeTree (_) => r
@@ -1744,8 +1741,11 @@ object Parsers {
17441741 case PRIVATE => Mod .Private ()
17451742 case PROTECTED => Mod .Protected ()
17461743 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+ }
17491749 }
17501750
17511751 /** Drop `private' modifier when followed by a qualifier.
@@ -1816,7 +1816,8 @@ object Parsers {
18161816 @ tailrec
18171817 def loop (mods : Modifiers ): Modifiers = {
18181818 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
18201821 val isAccessMod = accessModifierTokens contains in.token
18211822 val mods1 = addModifier(mods)
18221823 loop(if (isAccessMod) accessQualifierOpt(mods1) else mods1)
@@ -1957,7 +1958,8 @@ object Parsers {
19571958 }
19581959 }
19591960 else {
1960- if (isIdent(nme.INLINEkw )) mods = addModifier(mods)
1961+ if (isIdent(nme.inline) && in.isSoftModifierInParamModifierPosition)
1962+ mods = addModifier(mods)
19611963 mods = atPos(start) { mods | Param }
19621964 }
19631965 atPos(start, nameStart) {
@@ -2616,7 +2618,7 @@ object Parsers {
26162618 if (in.token == IMPLICIT || in.token == ERASED ) {
26172619 val start = in.offset
26182620 var imods = modifiers(funArgMods)
2619- if (isBindingIntro && ! isIdent(nme. INLINEkw ) )
2621+ if (isBindingIntro)
26202622 stats += implicitClosure(start, Location .InBlock , imods)
26212623 else
26222624 stats +++= localDef(start, imods)
0 commit comments