@@ -166,22 +166,24 @@ 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 )
170169 def isBindingIntro : Boolean = canStartBindingTokens contains in.token
171170 def isTemplateIntro : Boolean = templateIntroTokens contains in.token
172171 def isDclIntro : Boolean = dclIntroTokens contains in.token
173172 def isStatSeqEnd : Boolean = in.token == RBRACE || in.token == EOF
174173 def mustStartStat : Boolean = mustStartStatTokens contains in.token
175174
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+
176178 def isExprIntro : Boolean =
177- ( canStartExpressionTokens ` contains` in.token) &&
178- ( ! isIdent(nme. INLINEkw ) || lookaheadIn(canStartExpressionTokens))
179+ canStartExpressionTokens. contains( in.token) &&
180+ ! in.isSoftModifierInModifierPosition
179181
180182 def isDefIntro (allowedMods : BitSet ): Boolean =
181183 in.token == AT ||
182184 (defIntroTokens `contains` in.token) ||
183185 (allowedMods `contains` in.token) ||
184- isIdent(nme. INLINEkw ) && lookaheadIn( BitSet ( AT ) | defIntroTokens | allowedMods)
186+ in.isSoftModifierInModifierPosition
185187
186188 def isStatSep : Boolean =
187189 in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
@@ -455,14 +457,6 @@ object Parsers {
455457
456458 def commaSeparated [T ](part : () => T ): List [T ] = tokenSeparated(COMMA , part)
457459
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-
466460/* --------- OPERAND/OPERATOR STACK --------------------------------------- */
467461
468462 var opStack : List [OpInfo ] = Nil
@@ -841,7 +835,7 @@ object Parsers {
841835
842836 /** Is current ident a `*`, and is it followed by a `)` or `,`? */
843837 def isPostfixStar : Boolean =
844- in.name == nme.raw.STAR && lookaheadIn(BitSet (RPAREN , COMMA ))
838+ in.name == nme.raw.STAR && in. lookaheadIn(BitSet (RPAREN , COMMA ))
845839
846840 def infixTypeRest (t : Tree ): Tree =
847841 infixOps(t, canStartTypeTokens, refinedType, isType = true , isOperator = ! isPostfixStar)
@@ -899,7 +893,7 @@ object Parsers {
899893 val start = in.skipToken()
900894 typeBounds().withPos(Position (start, in.lastOffset, start))
901895 }
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 )))
903897 atPos(in.offset) { PrefixOp (typeIdent(), path(thisOK = true )) }
904898 else path(thisOK = false , handleSingletonType) match {
905899 case r @ SingletonTypeTree (_) => r
@@ -1744,8 +1738,11 @@ object Parsers {
17441738 case PRIVATE => Mod .Private ()
17451739 case PROTECTED => Mod .Protected ()
17461740 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+ }
17491746 }
17501747
17511748 /** Drop `private' modifier when followed by a qualifier.
@@ -1816,7 +1813,8 @@ object Parsers {
18161813 @ tailrec
18171814 def loop (mods : Modifiers ): Modifiers = {
18181815 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
18201818 val isAccessMod = accessModifierTokens contains in.token
18211819 val mods1 = addModifier(mods)
18221820 loop(if (isAccessMod) accessQualifierOpt(mods1) else mods1)
@@ -1957,7 +1955,7 @@ object Parsers {
19571955 }
19581956 }
19591957 else {
1960- if (isIdent(nme.INLINEkw )) mods = addModifier(mods)
1958+ if (isIdent(nme.`inline` )) mods = addModifier(mods)
19611959 mods = atPos(start) { mods | Param }
19621960 }
19631961 atPos(start, nameStart) {
@@ -2616,7 +2614,7 @@ object Parsers {
26162614 if (in.token == IMPLICIT || in.token == ERASED ) {
26172615 val start = in.offset
26182616 var imods = modifiers(funArgMods)
2619- if (isBindingIntro && ! isIdent(nme.INLINEkw ))
2617+ if (isBindingIntro && ! isIdent(nme.`inline` ))
26202618 stats += implicitClosure(start, Location .InBlock , imods)
26212619 else
26222620 stats +++= localDef(start, imods)
0 commit comments