@@ -190,6 +190,8 @@ object Parsers {
190
190
def isPureArrow (name : Name ): Boolean = isIdent(name) && Feature .pureFunsEnabled
191
191
def isPureArrow : Boolean = isPureArrow(nme.PUREARROW ) || isPureArrow(nme.PURECTXARROW )
192
192
def isErased = isIdent(nme.erased) && in.erasedEnabled
193
+ // Are we seeing an `erased` soft keyword that will not be an identifier?
194
+ def isErasedKw = isErased && in.isSoftModifierInParamModifierPosition
193
195
def isSimpleLiteral =
194
196
simpleLiteralTokens.contains(in.token)
195
197
|| isIdent(nme.raw.MINUS ) && numericLitTokens.contains(in.lookahead.token)
@@ -1545,8 +1547,8 @@ object Parsers {
1545
1547
else {
1546
1548
val paramStart = in.offset
1547
1549
def addErased () =
1548
- erasedArgs.addOne(isErased )
1549
- if isErased then { in.skipToken(); }
1550
+ erasedArgs.addOne(isErasedKw )
1551
+ if isErasedKw then { in.skipToken(); }
1550
1552
addErased()
1551
1553
val ts = in.currentRegion.withCommasExpected {
1552
1554
funArgType() match
@@ -2379,7 +2381,7 @@ object Parsers {
2379
2381
*/
2380
2382
def binding (mods : Modifiers ): Tree =
2381
2383
atSpan(in.offset) {
2382
- val mods1 = if isErased then addModifier(mods) else mods
2384
+ val mods1 = if isErasedKw then addModifier(mods) else mods
2383
2385
makeParameter(bindingName(), typedOpt(), mods1)
2384
2386
}
2385
2387
@@ -2578,7 +2580,7 @@ object Parsers {
2578
2580
else in.currentRegion.withCommasExpected {
2579
2581
var isFormalParams = false
2580
2582
def exprOrBinding () =
2581
- if isErased then isFormalParams = true
2583
+ if isErasedKw then isFormalParams = true
2582
2584
if isFormalParams then binding(Modifiers ())
2583
2585
else
2584
2586
val t = exprInParens()
@@ -3221,7 +3223,7 @@ object Parsers {
3221
3223
def param (): ValDef = {
3222
3224
val start = in.offset
3223
3225
var mods = impliedMods.withAnnotations(annotations())
3224
- if (isErased && in.isSoftModifierInParamModifierPosition)
3226
+ if isErasedKw then
3225
3227
mods = addModifier(mods)
3226
3228
if (ofClass) {
3227
3229
mods = addFlag(modifiers(start = mods), ParamAccessor )
@@ -3279,16 +3281,19 @@ object Parsers {
3279
3281
if prefix && ! isIdent(nme.using) && ! isIdent(nme.erased) then param() :: Nil
3280
3282
else
3281
3283
paramMods()
3282
- val firstParamMod =
3283
- var mods = EmptyModifiers
3284
- if isErased then mods = addModifier(mods)
3285
- mods
3286
3284
if givenOnly && ! impliedMods.is(Given ) then
3287
3285
syntaxError(em " `using` expected " )
3288
- val isParams =
3289
- ! impliedMods.is(Given )
3290
- || startParamTokens.contains(in.token)
3291
- || isIdent && (in.name == nme.inline || in.lookahead.isColon)
3286
+ val (firstParamMod, isParams) =
3287
+ var mods = EmptyModifiers
3288
+ if in.lookahead.isColon then
3289
+ (mods, true )
3290
+ else
3291
+ if isErased then mods = addModifier(mods)
3292
+ val isParams =
3293
+ ! impliedMods.is(Given )
3294
+ || startParamTokens.contains(in.token)
3295
+ || isIdent && (in.name == nme.inline || in.lookahead.isColon)
3296
+ (mods, isParams)
3292
3297
(if isParams then commaSeparated(() => param())
3293
3298
else contextTypes(ofClass, nparams, impliedMods)) match {
3294
3299
case Nil => Nil
0 commit comments