@@ -3389,7 +3389,7 @@ object Parsers {
3389
3389
*/
3390
3390
def importOrExportClause (leading : Token , mkTree : ImportConstr ): List [Tree ] = {
3391
3391
val offset = accept(leading)
3392
- commaSeparated(importExpr(mkTree)) match {
3392
+ commaSeparated(importExpr(leading, mkTree)) match {
3393
3393
case t :: rest =>
3394
3394
// The first import should start at the start offset of the keyword.
3395
3395
val firstPos =
@@ -3444,13 +3444,18 @@ object Parsers {
3444
3444
* NamedSelector ::= id [‘as’ (id | ‘_’)]
3445
3445
* WildCardSelector ::= ‘*' | ‘given’ [InfixType]
3446
3446
*/
3447
- def importExpr (mkTree : ImportConstr ): () => Tree =
3447
+ def importExpr (leading : Token , mkTree : ImportConstr ): () => Tree =
3448
+
3449
+ def exprName =
3450
+ (leading : @ unchecked) match
3451
+ case EXPORT => " export"
3452
+ case IMPORT => " import"
3448
3453
3449
3454
/** ‘*' | ‘_' */
3450
3455
def wildcardSelector () =
3451
3456
if in.token == USCORE && sourceVersion.isAtLeast(future) then
3452
3457
report.errorOrMigrationWarning(
3453
- em " `_` is no longer supported for a wildcard import ; use `*` instead ${rewriteNotice(`future-migration`)}" ,
3458
+ em " `_` is no longer supported for a wildcard $exprName ; use `*` instead ${rewriteNotice(`future-migration`)}" ,
3454
3459
in.sourcePos(),
3455
3460
from = future)
3456
3461
patch(source, Span (in.offset, in.offset + 1 ), " *" )
@@ -3469,7 +3474,7 @@ object Parsers {
3469
3474
if in.token == ARROW || isIdent(nme.as) then
3470
3475
if in.token == ARROW && sourceVersion.isAtLeast(future) then
3471
3476
report.errorOrMigrationWarning(
3472
- em " The import renaming `a => b` is no longer supported ; use `a as b` instead ${rewriteNotice(`future-migration`)}" ,
3477
+ em " The $exprName renaming `a => b` is no longer supported ; use `a as b` instead ${rewriteNotice(`future-migration`)}" ,
3473
3478
in.sourcePos(),
3474
3479
from = future)
3475
3480
patch(source, Span (in.offset, in.offset + 2 ),
@@ -3489,7 +3494,7 @@ object Parsers {
3489
3494
case _ =>
3490
3495
if isIdent(nme.raw.STAR ) then wildcardSelector()
3491
3496
else
3492
- if ! idOK then syntaxError(em " named imports cannot follow wildcard imports " )
3497
+ if ! idOK then syntaxError(em " named ${exprName} s cannot follow wildcard ${exprName} s " )
3493
3498
namedSelector(termIdent())
3494
3499
}
3495
3500
0 commit comments