@@ -1429,6 +1429,27 @@ trait Checking {
1429
1429
em """ Implementation restriction: cannot generate CanThrow capability for this kind of catch.
1430
1430
|CanThrow capabilities can only be generated $req. """ ,
1431
1431
pat.srcPos)
1432
+
1433
+ /** (1) Check that every named import selector refers to a type or value member of the
1434
+ * qualifier type.
1435
+ * (2) Check that no import selector is renamed more than once.
1436
+ */
1437
+ def checkImportSelectors (qualType : Type , selectors : List [untpd.ImportSelector ])(using Context ): Unit =
1438
+ val seen = mutable.Set .empty[Name ]
1439
+
1440
+ def checkIdent (sel : untpd.ImportSelector ): Unit =
1441
+ if sel.name != nme.ERROR
1442
+ && ! qualType.member(sel.name).exists
1443
+ && ! qualType.member(sel.name.toTypeName).exists
1444
+ then
1445
+ report.error(NotAMember (qualType, sel.name, " value" ), sel.imported.srcPos)
1446
+ if seen.contains(sel.name) then
1447
+ report.error(ImportRenamedTwice (sel.imported), sel.imported.srcPos)
1448
+ seen += sel.name
1449
+
1450
+ for sel <- selectors do
1451
+ if ! sel.isWildcard then checkIdent(sel)
1452
+ end checkImportSelectors
1432
1453
}
1433
1454
1434
1455
trait ReChecking extends Checking {
@@ -1466,4 +1487,5 @@ trait NoChecking extends ReChecking {
1466
1487
override def checkMembersOK (tp : Type , pos : SrcPos )(using Context ): Type = tp
1467
1488
override def checkInInlineContext (what : String , pos : SrcPos )(using Context ): Unit = ()
1468
1489
override def checkValidInfix (tree : untpd.InfixOp , meth : Symbol )(using Context ): Unit = ()
1490
+ override def checkImportSelectors (qualType : Type , selectors : List [untpd.ImportSelector ])(using Context ): Unit = ()
1469
1491
}
0 commit comments