@@ -230,6 +230,11 @@ object Parsers {
230230 else (staged & StageKind .Quoted ) != 0
231231 }
232232
233+ extension (td : TokenData = in)
234+ def isErased : Boolean =
235+ td.token == ERASED
236+ || td.isIdent(nme.erased) && featureEnabled(Feature .erasedTerms)
237+
233238/* ------------- ERROR HANDLING ------------------------------------------- */
234239
235240 /** The offset of the last time when a statement on a new line was definitely
@@ -1377,7 +1382,7 @@ object Parsers {
13771382 functionRest(Nil )
13781383 }
13791384 else {
1380- imods = modifiers(funTypeArgMods )
1385+ if in.isErased then imods = addModifier(imods )
13811386 val paramStart = in.offset
13821387 val ts = funArgType() match {
13831388 case Ident (name) if name != tpnme.WILDCARD && in.token == COLON =>
@@ -1864,7 +1869,7 @@ object Parsers {
18641869
18651870 def expr (location : Location ): Tree = {
18661871 val start = in.offset
1867- def isSpecialClosureStart = in.lookahead.token == ERASED
1872+ def isSpecialClosureStart = in.lookahead.isErased
18681873 if in.token == IMPLICIT then
18691874 closure(start, location, modifiers(BitSet (IMPLICIT )))
18701875 else if in.token == LPAREN && isSpecialClosureStart then
@@ -2096,7 +2101,7 @@ object Parsers {
20962101 Nil
20972102 else
20982103 var mods1 = mods
2099- if in.token == ERASED then mods1 = addModifier(mods1)
2104+ if in.isErased then mods1 = addModifier(mods1)
21002105 try
21012106 commaSeparated(() => binding(mods1))
21022107 finally
@@ -2695,6 +2700,7 @@ object Parsers {
26952700 case SEALED => Mod .Sealed ()
26962701 case IDENTIFIER =>
26972702 name match {
2703+ case nme.erased if featureEnabled(Feature .erasedTerms) => Mod .Erased ()
26982704 case nme.inline => Mod .Inline ()
26992705 case nme.opaque => Mod .Opaque ()
27002706 case nme.open => Mod .Open ()
@@ -2778,8 +2784,6 @@ object Parsers {
27782784 normalize(loop(start))
27792785 }
27802786
2781- val funTypeArgMods : BitSet = BitSet (ERASED )
2782-
27832787 /** Wrap annotation or constructor in New(...).<init> */
27842788 def wrapNew (tpt : Tree ): Select = Select (New (tpt), nme.CONSTRUCTOR )
27852789
@@ -2902,10 +2906,13 @@ object Parsers {
29022906 def addParamMod (mod : () => Mod ) = impliedMods = addMod(impliedMods, atSpan(in.skipToken()) { mod() })
29032907
29042908 def paramMods () =
2905- if in.token == IMPLICIT then addParamMod(() => Mod .Implicit ())
2909+ if in.token == IMPLICIT then
2910+ addParamMod(() => Mod .Implicit ())
29062911 else
2907- if isIdent(nme.using) then addParamMod(() => Mod .Given ())
2908- if in.token == ERASED then addParamMod(() => Mod .Erased ())
2912+ if isIdent(nme.using) then
2913+ addParamMod(() => Mod .Given ())
2914+ if in.isErased then
2915+ addParamMod(() => Mod .Erased ())
29092916
29102917 def param (): ValDef = {
29112918 val start = in.offset
0 commit comments