@@ -169,7 +169,7 @@ object Parsers {
169
169
def isSimpleLiteral = simpleLiteralTokens contains in.token
170
170
def isLiteral = literalTokens contains in.token
171
171
def isNumericLit = numericLitTokens contains in.token
172
- def isModifier = modifierTokens contains in.token
172
+ def isModifier = modifierTokens. contains( in.token) || isIdent(nme. INLINEkw )
173
173
def isBindingIntro = canStartBindingTokens contains in.token
174
174
def isTemplateIntro = templateIntroTokens contains in.token
175
175
def isDclIntro = dclIntroTokens contains in.token
@@ -178,13 +178,13 @@ object Parsers {
178
178
179
179
def isExprIntro =
180
180
(canStartExpressionTokens `contains` in.token) &&
181
- (in.token != INLINE || lookaheadIn(canStartExpressionTokens))
181
+ (! isIdent(nme. INLINEkw ) || lookaheadIn(canStartExpressionTokens))
182
182
183
183
def isDefIntro (allowedMods : BitSet ) =
184
184
in.token == AT ||
185
185
(defIntroTokens `contains` in.token) ||
186
- (allowedMods `contains` in.token) &&
187
- (in.token != INLINE || lookaheadIn(BitSet (AT ) | defIntroTokens | allowedMods) )
186
+ (allowedMods `contains` in.token) ||
187
+ isIdent(nme. INLINEkw ) && lookaheadIn(BitSet (AT ) | defIntroTokens | allowedMods)
188
188
189
189
def isStatSep : Boolean =
190
190
in.token == NEWLINE || in.token == NEWLINES || in.token == SEMI
@@ -461,7 +461,8 @@ object Parsers {
461
461
/** Is the token following the current one in `tokens`? */
462
462
def lookaheadIn (tokens : BitSet ): Boolean = {
463
463
val lookahead = in.lookaheadScanner
464
- lookahead.nextToken()
464
+ do lookahead.nextToken()
465
+ while (lookahead.token == NEWLINE || lookahead.token == NEWLINES )
465
466
tokens.contains(lookahead.token)
466
467
}
467
468
@@ -1212,21 +1213,22 @@ object Parsers {
1212
1213
atPos(in.skipToken()) { Return (if (isExprIntro) expr() else EmptyTree , EmptyTree ) }
1213
1214
case FOR =>
1214
1215
forExpr()
1215
- case INLINE =>
1216
- val start = in.skipToken()
1217
- in.token match {
1218
- case IF =>
1219
- ifExpr(start, InlineIf )
1220
- case _ =>
1221
- val t = postfixExpr()
1222
- if (in.token == MATCH ) matchExpr(t, start, InlineMatch )
1223
- else {
1224
- syntaxErrorOrIncomplete(" `match` or `if` expected but ${in.token} found" )
1225
- t
1226
- }
1227
- }
1228
1216
case _ =>
1229
- expr1Rest(postfixExpr(), location)
1217
+ if (isIdent(nme.INLINEkw )) {
1218
+ val start = in.skipToken()
1219
+ in.token match {
1220
+ case IF =>
1221
+ ifExpr(start, InlineIf )
1222
+ case _ =>
1223
+ val t = postfixExpr()
1224
+ if (in.token == MATCH ) matchExpr(t, start, InlineMatch )
1225
+ else {
1226
+ syntaxErrorOrIncomplete(" `match` or `if` expected but ${in.token} found" )
1227
+ t
1228
+ }
1229
+ }
1230
+ }
1231
+ else expr1Rest(postfixExpr(), location)
1230
1232
}
1231
1233
1232
1234
def expr1Rest (t : Tree , location : Location .Value ) = in.token match {
@@ -1771,18 +1773,18 @@ object Parsers {
1771
1773
1772
1774
/* -------- MODIFIERS and ANNOTATIONS ------------------------------------------- */
1773
1775
1774
- private def modOfToken (tok : Int ): Mod = tok match {
1776
+ private def modOfToken (tok : Int , name : Name ): Mod = tok match {
1775
1777
case ABSTRACT => Mod .Abstract ()
1776
1778
case FINAL => Mod .Final ()
1777
1779
case IMPLICIT => Mod .Implicit ()
1778
1780
case ERASED => Mod .Erased ()
1779
- case INLINE => Mod .Inline ()
1780
1781
case TRANSPARENT => Mod .Transparent ()
1781
1782
case LAZY => Mod .Lazy ()
1782
1783
case OVERRIDE => Mod .Override ()
1783
1784
case PRIVATE => Mod .Private ()
1784
1785
case PROTECTED => Mod .Protected ()
1785
1786
case SEALED => Mod .Sealed ()
1787
+ case IDENTIFIER if name == nme.INLINEkw => Mod .Inline ()
1786
1788
}
1787
1789
1788
1790
/** Drop `private' modifier when followed by a qualifier.
@@ -1798,7 +1800,8 @@ object Parsers {
1798
1800
1799
1801
private def addModifier (mods : Modifiers ): Modifiers = {
1800
1802
val tok = in.token
1801
- val mod = atPos(in.skipToken()) { modOfToken(tok) }
1803
+ val name = in.name
1804
+ val mod = atPos(in.skipToken()) { modOfToken(tok, name) }
1802
1805
1803
1806
if (mods is mod.flags) syntaxError(RepeatedModifier (mod.flags.toString))
1804
1807
addMod(mods, mod)
@@ -1846,12 +1849,13 @@ object Parsers {
1846
1849
* Modifier ::= LocalModifier
1847
1850
* | AccessModifier
1848
1851
* | override
1849
- * LocalModifier ::= abstract | final | sealed | implicit | lazy
1852
+ * LocalModifier ::= abstract | final | sealed | implicit | lazy | erased | inline
1850
1853
*/
1851
1854
def modifiers (allowed : BitSet = modifierTokens, start : Modifiers = Modifiers ()): Modifiers = {
1852
1855
@ tailrec
1853
1856
def loop (mods : Modifiers ): Modifiers = {
1854
- if (allowed contains in.token) {
1857
+ if (allowed.contains(in.token) ||
1858
+ isIdent(nme.INLINEkw ) && localModifierTokens.subsetOf(allowed)) {
1855
1859
val isAccessMod = accessModifierTokens contains in.token
1856
1860
val mods1 = addModifier(mods)
1857
1861
loop(if (isAccessMod) accessQualifierOpt(mods1) else mods1)
@@ -1888,10 +1892,7 @@ object Parsers {
1888
1892
*/
1889
1893
def annot () =
1890
1894
adjustStart(accept(AT )) {
1891
- val tpe =
1892
- if (in.token == INLINE ) atPos(in.skipToken()) { BackquotedIdent (tpnme.INLINEkw ) }
1893
- else simpleType()
1894
- ensureApplied(parArgumentExprss(wrapNew(tpe)))
1895
+ ensureApplied(parArgumentExprss(wrapNew(simpleType())))
1895
1896
}
1896
1897
1897
1898
def annotations (skipNewLines : Boolean = false ): List [Tree ] = {
@@ -2648,7 +2649,7 @@ object Parsers {
2648
2649
if (in.token == IMPLICIT || in.token == ERASED ) {
2649
2650
val start = in.offset
2650
2651
var imods = modifiers(funArgMods)
2651
- if (isBindingIntro)
2652
+ if (isBindingIntro && ! isIdent(nme. INLINEkw ) )
2652
2653
stats += implicitClosure(start, Location .InBlock , imods)
2653
2654
else if (in.token == MATCH )
2654
2655
stats += implicitMatch(start, imods)
0 commit comments