@@ -28,7 +28,8 @@ import util.Chars
2828import scala .annotation .{tailrec , switch }
2929import rewrites .Rewrites .{patch , overlapsPatch }
3030import reporting ._
31- import config .Feature .{sourceVersion , migrateTo3 , dependentEnabled , symbolLiteralsEnabled }
31+ import config .Feature
32+ import config .Feature .{sourceVersion , migrateTo3 }
3233import config .SourceVersion ._
3334import config .SourceVersion
3435
@@ -179,6 +180,7 @@ object Parsers {
179180
180181 def isIdent = in.isIdent
181182 def isIdent (name : Name ) = in.isIdent(name)
183+ def isErased = isIdent(nme.erased) && in.erasedEnabled
182184 def isSimpleLiteral =
183185 simpleLiteralTokens.contains(in.token)
184186 || isIdent(nme.raw.MINUS ) && numericLitTokens.contains(in.lookahead.token)
@@ -446,19 +448,18 @@ object Parsers {
446448 * Parameters appear in reverse order.
447449 */
448450 var placeholderParams : List [ValDef ] = Nil
449- var languageImportContext : Context = ctx
450451
451452 def checkNoEscapingPlaceholders [T ](op : => T ): T =
452453 val savedPlaceholderParams = placeholderParams
453- val savedLanguageImportContext = languageImportContext
454+ val savedLanguageImportContext = in. languageImportContext
454455 placeholderParams = Nil
455456 try op
456457 finally
457458 placeholderParams match
458459 case vd :: _ => syntaxError(UnboundPlaceholderParameter (), vd.span)
459460 case _ =>
460461 placeholderParams = savedPlaceholderParams
461- languageImportContext = savedLanguageImportContext
462+ in. languageImportContext = savedLanguageImportContext
462463
463464 def isWildcard (t : Tree ): Boolean = t match {
464465 case Ident (name1) => placeholderParams.nonEmpty && name1 == placeholderParams.head.name
@@ -1141,7 +1142,7 @@ object Parsers {
11411142 Quote (t)
11421143 }
11431144 else
1144- if ! symbolLiteralsEnabled( using languageImportContext ) then
1145+ if ! in.featureEnabled( Feature .symbolLiterals ) then
11451146 report.errorOrMigrationWarning(
11461147 em """ symbol literal ' ${in.name} is no longer supported,
11471148 |use a string literal " ${in.name}" or an application Symbol(" ${in.name}") instead,
@@ -1374,7 +1375,7 @@ object Parsers {
13741375 functionRest(Nil )
13751376 }
13761377 else {
1377- imods = modifiers(funTypeArgMods )
1378+ if isErased then imods = addModifier(imods )
13781379 val paramStart = in.offset
13791380 val ts = funArgType() match {
13801381 case Ident (name) if name != tpnme.WILDCARD && in.token == COLON =>
@@ -1572,7 +1573,7 @@ object Parsers {
15721573 typeIdent()
15731574 else
15741575 def singletonArgs (t : Tree ): Tree =
1575- if in.token == LPAREN && dependentEnabled( using languageImportContext )
1576+ if in.token == LPAREN && in.featureEnabled( Feature .dependent )
15761577 then singletonArgs(AppliedTypeTree (t, inParens(commaSeparated(singleton))))
15771578 else t
15781579 singletonArgs(simpleType1())
@@ -1861,7 +1862,7 @@ object Parsers {
18611862
18621863 def expr (location : Location ): Tree = {
18631864 val start = in.offset
1864- def isSpecialClosureStart = in.lookahead.token == ERASED
1865+ def isSpecialClosureStart = in.lookahead.isIdent(nme.erased) && in.erasedEnabled
18651866 if in.token == IMPLICIT then
18661867 closure(start, location, modifiers(BitSet (IMPLICIT )))
18671868 else if in.token == LPAREN && isSpecialClosureStart then
@@ -2093,7 +2094,7 @@ object Parsers {
20932094 Nil
20942095 else
20952096 var mods1 = mods
2096- if in.token == ERASED then mods1 = addModifier(mods1)
2097+ if isErased then mods1 = addModifier(mods1)
20972098 try
20982099 commaSeparated(() => binding(mods1))
20992100 finally
@@ -2684,14 +2685,14 @@ object Parsers {
26842685 case FINAL => Mod .Final ()
26852686 case IMPLICIT => Mod .Implicit ()
26862687 case GIVEN => Mod .Given ()
2687- case ERASED => Mod .Erased ()
26882688 case LAZY => Mod .Lazy ()
26892689 case OVERRIDE => Mod .Override ()
26902690 case PRIVATE => Mod .Private ()
26912691 case PROTECTED => Mod .Protected ()
26922692 case SEALED => Mod .Sealed ()
26932693 case IDENTIFIER =>
26942694 name match {
2695+ case nme.erased if in.erasedEnabled => Mod .Erased ()
26952696 case nme.inline => Mod .Inline ()
26962697 case nme.opaque => Mod .Opaque ()
26972698 case nme.open => Mod .Open ()
@@ -2775,8 +2776,6 @@ object Parsers {
27752776 normalize(loop(start))
27762777 }
27772778
2778- val funTypeArgMods : BitSet = BitSet (ERASED )
2779-
27802779 /** Wrap annotation or constructor in New(...).<init> */
27812780 def wrapNew (tpt : Tree ): Select = Select (New (tpt), nme.CONSTRUCTOR )
27822781
@@ -2899,10 +2898,13 @@ object Parsers {
28992898 def addParamMod (mod : () => Mod ) = impliedMods = addMod(impliedMods, atSpan(in.skipToken()) { mod() })
29002899
29012900 def paramMods () =
2902- if in.token == IMPLICIT then addParamMod(() => Mod .Implicit ())
2901+ if in.token == IMPLICIT then
2902+ addParamMod(() => Mod .Implicit ())
29032903 else
2904- if isIdent(nme.using) then addParamMod(() => Mod .Given ())
2905- if in.token == ERASED then addParamMod(() => Mod .Erased ())
2904+ if isIdent(nme.using) then
2905+ addParamMod(() => Mod .Given ())
2906+ if isErased then
2907+ addParamMod(() => Mod .Erased ())
29062908
29072909 def param (): ValDef = {
29082910 val start = in.offset
@@ -2959,7 +2961,7 @@ object Parsers {
29592961 if in.token == RPAREN && ! prefix && ! impliedMods.is(Given ) then Nil
29602962 else
29612963 val clause =
2962- if prefix && ! isIdent(nme.using) then param() :: Nil
2964+ if prefix && ! isIdent(nme.using) && ! isIdent(nme.erased) then param() :: Nil
29632965 else
29642966 paramMods()
29652967 if givenOnly && ! impliedMods.is(Given ) then
@@ -3032,7 +3034,7 @@ object Parsers {
30323034 def mkImport (outermost : Boolean = false ): ImportConstr = (tree, selectors) =>
30333035 val imp = Import (tree, selectors)
30343036 if isLanguageImport(tree) then
3035- languageImportContext = languageImportContext.importContext(imp, NoSymbol )
3037+ in. languageImportContext = in. languageImportContext.importContext(imp, NoSymbol )
30363038 for
30373039 case ImportSelector (id @ Ident (imported), EmptyTree , _) <- selectors
30383040 if allSourceVersionNames.contains(imported)
0 commit comments