@@ -1072,33 +1072,17 @@ class Namer { typer: Typer =>
1072
1072
/** The forwarders defined by export `exp` */
1073
1073
private def exportForwarders (exp : Export )(using Context ): List [tpd.MemberDef ] =
1074
1074
val buf = new mutable.ListBuffer [tpd.MemberDef ]
1075
- val Export (expr, selectors0 ) = exp
1075
+ val Export (expr, selectors ) = exp
1076
1076
if expr.isEmpty then
1077
1077
report.error(em " Export selector must have prefix and `.` " , exp.srcPos)
1078
1078
return Nil
1079
1079
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
-
1097
1080
val path = typedAheadExpr(expr, AnySelectionProto )
1098
1081
checkLegalExportPath(path, selectors)
1099
1082
lazy val wildcardBound = importBound(selectors, isGiven = false )
1100
1083
lazy val givenBound = importBound(selectors, isGiven = true )
1101
1084
1085
+ val targets = mutable.Set [Name ]()
1102
1086
def canForward (mbr : SingleDenotation , alias : TermName ): CanForward = {
1103
1087
import CanForward .*
1104
1088
val sym = mbr.symbol
@@ -1108,8 +1092,8 @@ class Namer { typer: Typer =>
1108
1092
Skip
1109
1093
else if cls.derivesFrom(sym.owner) && (sym.owner == cls || ! sym.is(Deferred )) then
1110
1094
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 " )
1113
1097
else if sym.is(Override ) then
1114
1098
sym.allOverriddenSymbols.find(
1115
1099
other => cls.derivesFrom(other.owner) && ! other.is(Deferred )
@@ -1208,6 +1192,7 @@ class Namer { typer: Typer =>
1208
1192
val size = buf.size
1209
1193
val mbrs = List (name, name.toTypeName).flatMap(path.tpe.member(_).alternatives)
1210
1194
mbrs.foreach(addForwarder(alias, _, span))
1195
+ targets += alias
1211
1196
if buf.size == size then
1212
1197
val reason = mbrs.map(canForward(_, alias)).collect {
1213
1198
case CanForward .No (whyNot) => i " \n $path. $name cannot be exported because it $whyNot"
0 commit comments