@@ -1072,33 +1072,17 @@ class Namer { typer: Typer =>
10721072 /** The forwarders defined by export `exp` */
10731073 private def exportForwarders (exp : Export )(using Context ): List [tpd.MemberDef ] =
10741074 val buf = new mutable.ListBuffer [tpd.MemberDef ]
1075- val Export (expr, selectors0 ) = exp
1075+ val Export (expr, selectors ) = exp
10761076 if expr.isEmpty then
10771077 report.error(em " Export selector must have prefix and `.` " , exp.srcPos)
10781078 return Nil
10791079
1080- val renamed = mutable.Set [Name ]()
1081- val selectors = selectors0 map {
1082- case sel @ ImportSelector (imported, id @ Ident (alias), bound) if alias != nme.WILDCARD =>
1083- def noAliasSelector =
1084- cpy.ImportSelector (sel)(imported, EmptyTree , bound).asInstanceOf [ImportSelector ]
1085- if renamed.contains(alias) then
1086- report.error(i " duplicate rename target " , id.srcPos)
1087- noAliasSelector
1088- else if alias == imported.name then
1089- report.warning(i " redundant rename in export " , id.srcPos)
1090- noAliasSelector
1091- else
1092- renamed += alias
1093- sel
1094- case sel => sel
1095- }
1096-
10971080 val path = typedAheadExpr(expr, AnySelectionProto )
10981081 checkLegalExportPath(path, selectors)
10991082 lazy val wildcardBound = importBound(selectors, isGiven = false )
11001083 lazy val givenBound = importBound(selectors, isGiven = true )
11011084
1085+ val targets = mutable.Set [Name ]()
11021086 def canForward (mbr : SingleDenotation , alias : TermName ): CanForward = {
11031087 import CanForward .*
11041088 val sym = mbr.symbol
@@ -1108,8 +1092,8 @@ class Namer { typer: Typer =>
11081092 Skip
11091093 else if cls.derivesFrom(sym.owner) && (sym.owner == cls || ! sym.is(Deferred )) then
11101094 No (i " is already a member of $cls" )
1111- else if alias == mbr.name.toTermName && renamed .contains(alias) then
1112- No (i " clashes with a renamed export " )
1095+ else if targets .contains(alias) then
1096+ No (i " clashes with another export in the same export clause " )
11131097 else if sym.is(Override ) then
11141098 sym.allOverriddenSymbols.find(
11151099 other => cls.derivesFrom(other.owner) && ! other.is(Deferred )
@@ -1208,6 +1192,7 @@ class Namer { typer: Typer =>
12081192 val size = buf.size
12091193 val mbrs = List (name, name.toTypeName).flatMap(path.tpe.member(_).alternatives)
12101194 mbrs.foreach(addForwarder(alias, _, span))
1195+ targets += alias
12111196 if buf.size == size then
12121197 val reason = mbrs.map(canForward(_, alias)).collect {
12131198 case CanForward .No (whyNot) => i " \n $path. $name cannot be exported because it $whyNot"
0 commit comments