@@ -3419,7 +3419,7 @@ object Parsers {
3419
3419
*/
3420
3420
def importOrExportClause (leading : Token , mkTree : ImportConstr ): List [Tree ] = {
3421
3421
val offset = accept(leading)
3422
- commaSeparated(importExpr(mkTree)) match {
3422
+ commaSeparated(importExpr(leading, mkTree)) match {
3423
3423
case t :: rest =>
3424
3424
// The first import should start at the start offset of the keyword.
3425
3425
val firstPos =
@@ -3474,13 +3474,18 @@ object Parsers {
3474
3474
* NamedSelector ::= id [‘as’ (id | ‘_’)]
3475
3475
* WildCardSelector ::= ‘*' | ‘given’ [InfixType]
3476
3476
*/
3477
- def importExpr (mkTree : ImportConstr ): () => Tree =
3477
+ def importExpr (leading : Token , mkTree : ImportConstr ): () => Tree =
3478
+
3479
+ def exprName =
3480
+ (leading : @ unchecked) match
3481
+ case EXPORT => " export"
3482
+ case IMPORT => " import"
3478
3483
3479
3484
/** ‘*' | ‘_' */
3480
3485
def wildcardSelector () =
3481
3486
if in.token == USCORE && sourceVersion.isAtLeast(future) then
3482
3487
report.errorOrMigrationWarning(
3483
- em " `_` is no longer supported for a wildcard import ; use `*` instead ${rewriteNotice(`future-migration`)}" ,
3488
+ em " `_` is no longer supported for a wildcard $exprName ; use `*` instead ${rewriteNotice(`future-migration`)}" ,
3484
3489
in.sourcePos(),
3485
3490
from = future)
3486
3491
patch(source, Span (in.offset, in.offset + 1 ), " *" )
@@ -3499,7 +3504,7 @@ object Parsers {
3499
3504
if in.token == ARROW || isIdent(nme.as) then
3500
3505
if in.token == ARROW && sourceVersion.isAtLeast(future) then
3501
3506
report.errorOrMigrationWarning(
3502
- em " The import renaming `a => b` is no longer supported ; use `a as b` instead ${rewriteNotice(`future-migration`)}" ,
3507
+ em " The $exprName renaming `a => b` is no longer supported ; use `a as b` instead ${rewriteNotice(`future-migration`)}" ,
3503
3508
in.sourcePos(),
3504
3509
from = future)
3505
3510
patch(source, Span (in.offset, in.offset + 2 ),
@@ -3519,7 +3524,7 @@ object Parsers {
3519
3524
case _ =>
3520
3525
if isIdent(nme.raw.STAR ) then wildcardSelector()
3521
3526
else
3522
- if ! idOK then syntaxError(em " named imports cannot follow wildcard imports " )
3527
+ if ! idOK then syntaxError(em " named ${exprName} s cannot follow wildcard ${exprName} s " )
3523
3528
namedSelector(termIdent())
3524
3529
}
3525
3530
0 commit comments