Skip to content

Commit 7e03fee

Browse files
committed
Fix parser not recognizing using erased X
By parsing the flags of the first parameter eagerly.
1 parent 90292c0 commit 7e03fee

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,10 +2322,11 @@ object Parsers {
23222322
if in.token == RPAREN then
23232323
Nil
23242324
else
2325-
var mods1 = mods
2326-
if isErased then mods1 = addModifier(mods1)
23272325
try
2328-
commaSeparated(() => binding(mods1))
2326+
commaSeparated(() =>
2327+
val mods1 = if isErased then addModifier(mods) else mods
2328+
binding(mods1)
2329+
)
23292330
finally
23302331
accept(RPAREN)
23312332
else {
@@ -3249,14 +3250,22 @@ object Parsers {
32493250
if prefix && !isIdent(nme.using) && !isIdent(nme.erased) then param() :: Nil
32503251
else
32513252
paramMods()
3253+
val firstParamMod =
3254+
var mods = EmptyModifiers
3255+
if isErased then mods = addModifier(mods)
3256+
if in.name == nme.inline then mods = addModifier(mods)
3257+
mods
32523258
if givenOnly && !impliedMods.is(Given) then
32533259
syntaxError(em"`using` expected")
32543260
val isParams =
32553261
!impliedMods.is(Given)
32563262
|| startParamTokens.contains(in.token)
3257-
|| isIdent && (in.name == nme.inline || in.name == nme.erased || in.lookahead.isColon)
3258-
if isParams then commaSeparated(() => param())
3259-
else contextTypes(ofClass, nparams, impliedMods)
3263+
|| isIdent && in.lookahead.isColon
3264+
(if isParams then commaSeparated(() => param())
3265+
else contextTypes(ofClass, nparams, impliedMods)) match {
3266+
case Nil => Nil
3267+
case (h :: t) => h.withAddedFlags(firstParamMod.flags) :: t
3268+
}
32603269
checkVarArgsRules(clause)
32613270
clause
32623271
}

0 commit comments

Comments
 (0)