@@ -746,20 +746,23 @@ object Checking {
746746 EmptyTree
747747
748748 for case imp @ Import (qual, selectors) <- trees do
749+ def isAllowedImport (sel : untpd.ImportSelector ) =
750+ val name = Feature .experimental(sel.name)
751+ name == Feature .scala2macros || name == Feature .erasedDefinitions
752+
749753 languageImport(qual) match
750754 case Some (nme.experimental)
751- if ! ctx.owner.isInExperimentalScope
752- && selectors.exists(sel => experimental(sel.name) != scala2macros && experimental(sel.name) != erasedDefinitions) =>
755+ if ! ctx.owner.isInExperimentalScope && ! selectors.forall(isAllowedImport) =>
753756 def check (stable : => String ) =
754- checkExperimentalFeature(" features" , imp.srcPos,
757+ Feature . checkExperimentalFeature(" features" , imp.srcPos,
755758 s " \n\n Note: the scope enclosing the import is not considered experimental because it contains the \n non-experimental $stable" )
756759 if ctx.owner.is(Package ) then
757760 // allow top-level experimental imports if all definitions are @experimental
758761 nonExperimentalStat(trees) match
759762 case EmptyTree =>
760763 case tree : MemberDef => check(i " ${tree.symbol}" )
761764 case tree => check(i " expression ${tree}" )
762- else checkExperimentalFeature(" features" , imp.srcPos)
765+ else Feature . checkExperimentalFeature(" features" , imp.srcPos)
763766 case _ =>
764767 end checkExperimentalImports
765768}
0 commit comments