@@ -28,7 +28,8 @@ import util.Chars
28
28
import scala .annotation .{tailrec , switch }
29
29
import rewrites .Rewrites .{patch , overlapsPatch }
30
30
import reporting ._
31
- import config .Feature .{sourceVersion , migrateTo3 , dependentEnabled , symbolLiteralsEnabled }
31
+ import config .Feature
32
+ import config .Feature .{sourceVersion , migrateTo3 }
32
33
import config .SourceVersion ._
33
34
import config .SourceVersion
34
35
@@ -179,6 +180,7 @@ object Parsers {
179
180
180
181
def isIdent = in.isIdent
181
182
def isIdent (name : Name ) = in.isIdent(name)
183
+ def isErased = isIdent(nme.erased) && in.erasedEnabled
182
184
def isSimpleLiteral =
183
185
simpleLiteralTokens.contains(in.token)
184
186
|| isIdent(nme.raw.MINUS ) && numericLitTokens.contains(in.lookahead.token)
@@ -446,19 +448,18 @@ object Parsers {
446
448
* Parameters appear in reverse order.
447
449
*/
448
450
var placeholderParams : List [ValDef ] = Nil
449
- var languageImportContext : Context = ctx
450
451
451
452
def checkNoEscapingPlaceholders [T ](op : => T ): T =
452
453
val savedPlaceholderParams = placeholderParams
453
- val savedLanguageImportContext = languageImportContext
454
+ val savedLanguageImportContext = in. languageImportContext
454
455
placeholderParams = Nil
455
456
try op
456
457
finally
457
458
placeholderParams match
458
459
case vd :: _ => syntaxError(UnboundPlaceholderParameter (), vd.span)
459
460
case _ =>
460
461
placeholderParams = savedPlaceholderParams
461
- languageImportContext = savedLanguageImportContext
462
+ in. languageImportContext = savedLanguageImportContext
462
463
463
464
def isWildcard (t : Tree ): Boolean = t match {
464
465
case Ident (name1) => placeholderParams.nonEmpty && name1 == placeholderParams.head.name
@@ -1141,7 +1142,7 @@ object Parsers {
1141
1142
Quote (t)
1142
1143
}
1143
1144
else
1144
- if ! symbolLiteralsEnabled( using languageImportContext ) then
1145
+ if ! in.featureEnabled( Feature .symbolLiterals ) then
1145
1146
report.errorOrMigrationWarning(
1146
1147
em """ symbol literal ' ${in.name} is no longer supported,
1147
1148
|use a string literal " ${in.name}" or an application Symbol(" ${in.name}") instead,
@@ -1374,7 +1375,7 @@ object Parsers {
1374
1375
functionRest(Nil )
1375
1376
}
1376
1377
else {
1377
- imods = modifiers(funTypeArgMods )
1378
+ if isErased then imods = addModifier(imods )
1378
1379
val paramStart = in.offset
1379
1380
val ts = funArgType() match {
1380
1381
case Ident (name) if name != tpnme.WILDCARD && in.token == COLON =>
@@ -1572,7 +1573,7 @@ object Parsers {
1572
1573
typeIdent()
1573
1574
else
1574
1575
def singletonArgs (t : Tree ): Tree =
1575
- if in.token == LPAREN && dependentEnabled( using languageImportContext )
1576
+ if in.token == LPAREN && in.featureEnabled( Feature .dependent )
1576
1577
then singletonArgs(AppliedTypeTree (t, inParens(commaSeparated(singleton))))
1577
1578
else t
1578
1579
singletonArgs(simpleType1())
@@ -1861,7 +1862,7 @@ object Parsers {
1861
1862
1862
1863
def expr (location : Location ): Tree = {
1863
1864
val start = in.offset
1864
- def isSpecialClosureStart = in.lookahead.token == ERASED
1865
+ def isSpecialClosureStart = in.lookahead.isIdent(nme.erased) && in.erasedEnabled
1865
1866
if in.token == IMPLICIT then
1866
1867
closure(start, location, modifiers(BitSet (IMPLICIT )))
1867
1868
else if in.token == LPAREN && isSpecialClosureStart then
@@ -2093,7 +2094,7 @@ object Parsers {
2093
2094
Nil
2094
2095
else
2095
2096
var mods1 = mods
2096
- if in.token == ERASED then mods1 = addModifier(mods1)
2097
+ if isErased then mods1 = addModifier(mods1)
2097
2098
try
2098
2099
commaSeparated(() => binding(mods1))
2099
2100
finally
@@ -2684,14 +2685,14 @@ object Parsers {
2684
2685
case FINAL => Mod .Final ()
2685
2686
case IMPLICIT => Mod .Implicit ()
2686
2687
case GIVEN => Mod .Given ()
2687
- case ERASED => Mod .Erased ()
2688
2688
case LAZY => Mod .Lazy ()
2689
2689
case OVERRIDE => Mod .Override ()
2690
2690
case PRIVATE => Mod .Private ()
2691
2691
case PROTECTED => Mod .Protected ()
2692
2692
case SEALED => Mod .Sealed ()
2693
2693
case IDENTIFIER =>
2694
2694
name match {
2695
+ case nme.erased if in.erasedEnabled => Mod .Erased ()
2695
2696
case nme.inline => Mod .Inline ()
2696
2697
case nme.opaque => Mod .Opaque ()
2697
2698
case nme.open => Mod .Open ()
@@ -2775,8 +2776,6 @@ object Parsers {
2775
2776
normalize(loop(start))
2776
2777
}
2777
2778
2778
- val funTypeArgMods : BitSet = BitSet (ERASED )
2779
-
2780
2779
/** Wrap annotation or constructor in New(...).<init> */
2781
2780
def wrapNew (tpt : Tree ): Select = Select (New (tpt), nme.CONSTRUCTOR )
2782
2781
@@ -2899,10 +2898,13 @@ object Parsers {
2899
2898
def addParamMod (mod : () => Mod ) = impliedMods = addMod(impliedMods, atSpan(in.skipToken()) { mod() })
2900
2899
2901
2900
def paramMods () =
2902
- if in.token == IMPLICIT then addParamMod(() => Mod .Implicit ())
2901
+ if in.token == IMPLICIT then
2902
+ addParamMod(() => Mod .Implicit ())
2903
2903
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 ())
2906
2908
2907
2909
def param (): ValDef = {
2908
2910
val start = in.offset
@@ -2959,7 +2961,7 @@ object Parsers {
2959
2961
if in.token == RPAREN && ! prefix && ! impliedMods.is(Given ) then Nil
2960
2962
else
2961
2963
val clause =
2962
- if prefix && ! isIdent(nme.using) then param() :: Nil
2964
+ if prefix && ! isIdent(nme.using) && ! isIdent(nme.erased) then param() :: Nil
2963
2965
else
2964
2966
paramMods()
2965
2967
if givenOnly && ! impliedMods.is(Given ) then
@@ -3032,7 +3034,7 @@ object Parsers {
3032
3034
def mkImport (outermost : Boolean = false ): ImportConstr = (tree, selectors) =>
3033
3035
val imp = Import (tree, selectors)
3034
3036
if isLanguageImport(tree) then
3035
- languageImportContext = languageImportContext.importContext(imp, NoSymbol )
3037
+ in. languageImportContext = in. languageImportContext.importContext(imp, NoSymbol )
3036
3038
for
3037
3039
case ImportSelector (id @ Ident (imported), EmptyTree , _) <- selectors
3038
3040
if allSourceVersionNames.contains(imported)
0 commit comments