Skip to content

Commit 146ef21

Browse files
committed
Rename erasedName -> targetName
1 parent 56a1cbc commit 146ef21

File tree

13 files changed

+32
-33
lines changed

13 files changed

+32
-33
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
891891
* on select(sym: Symbol).
892892
*/
893893
def selectWithSig(sym: Symbol)(using Context): Tree =
894-
selectWithSig(sym.name, sym.signature, sym.erasedName)
894+
selectWithSig(sym.name, sym.signature, sym.targetName)
895895

896896
/** A unary apply node with given argument: `tree(arg)` */
897897
def appliedTo(arg: Tree)(using Context): Apply =

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,12 @@ object Denotations {
347347
}
348348

349349
/** The alternative of this denotation that has a type matching `targetType` when seen
350-
* as a member of type `site` and that has an erased name matching `targetName`, or
350+
* as a member of type `site` and that has a target name matching `targetName`, or
351351
* `NoDenotation` if none exists.
352352
*/
353353
def matchingDenotation(site: Type, targetType: Type, targetName: Name)(using Context): SingleDenotation = {
354354
def qualifies(sym: Symbol) =
355-
site.memberInfo(sym).matchesLoosely(targetType) && targetNamesMatch(sym.erasedName, targetName)
355+
site.memberInfo(sym).matchesLoosely(targetType) && targetNamesMatch(sym.targetName, targetName)
356356
if (isOverloaded)
357357
atSignature(targetType.signature, targetName, site, relaxed = true) match {
358358
case sd: SingleDenotation => sd.matchingDenotation(site, targetType, targetName)
@@ -624,7 +624,7 @@ object Denotations {
624624
relaxed
625625
case noMatch =>
626626
false
627-
if sigMatches && targetNamesMatch(symbol.erasedName, targetName) then this
627+
if sigMatches && targetNamesMatch(symbol.targetName, targetName) then this
628628
else NoDenotation
629629

630630
def matchesImportBound(bound: Type)(using Context): Boolean =
@@ -986,7 +986,7 @@ object Denotations {
986986
final def last: SingleDenotation = this
987987

988988
def matches(other: SingleDenotation)(using Context): Boolean =
989-
targetNamesMatch(symbol.erasedName, other.symbol.erasedName)
989+
targetNamesMatch(symbol.targetName, other.symbol.targetName)
990990
&& {
991991
val d = signature.matchDegree(other.signature)
992992
d match

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ object SymDenotations {
513513
myTargetName = name
514514

515515
/** The name given in a `@targetName` annotation if one is present, `name` otherwise */
516-
def erasedName(using Context): Name =
516+
def targetName(using Context): Name =
517517
if myTargetName == null then
518518
val carrier: SymDenotation =
519519
if isAllOf(ModuleClass | Synthetic) then companionClass else this
@@ -1256,7 +1256,7 @@ object SymDenotations {
12561256
final def matchingDecl(inClass: Symbol, site: Type)(using Context): Symbol = {
12571257
var denot = inClass.info.nonPrivateDecl(name)
12581258
if (denot.isTerm) // types of the same name always match
1259-
denot = denot.matchingDenotation(site, site.memberInfo(symbol), symbol.erasedName)
1259+
denot = denot.matchingDenotation(site, site.memberInfo(symbol), symbol.targetName)
12601260
denot.symbol
12611261
}
12621262

@@ -1265,7 +1265,7 @@ object SymDenotations {
12651265
final def matchingMember(site: Type)(using Context): Symbol = {
12661266
var denot = site.nonPrivateMember(name)
12671267
if (denot.isTerm) // types of the same name always match
1268-
denot = denot.matchingDenotation(site, site.memberInfo(symbol), symbol.erasedName)
1268+
denot = denot.matchingDenotation(site, site.memberInfo(symbol), symbol.targetName)
12691269
denot.symbol
12701270
}
12711271

@@ -2336,7 +2336,7 @@ object SymDenotations {
23362336
override def mapInfo(f: Type => Type)(using Context): SingleDenotation = this
23372337

23382338
override def matches(other: SingleDenotation)(using Context): Boolean = false
2339-
override def erasedName(using Context): Name = EmptyTermName
2339+
override def targetName(using Context): Name = EmptyTermName
23402340
override def mapInherited(ownDenots: PreDenotation, prevDenots: PreDenotation, pre: Type)(using Context): SingleDenotation = this
23412341
override def filterWithPredicate(p: SingleDenotation => Boolean): SingleDenotation = this
23422342
override def filterDisjoint(denots: PreDenotation)(using Context): SingleDenotation = this

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,7 @@ object Types {
20842084
}
20852085

20862086
private def disambiguate(d: Denotation)(using Context): Denotation =
2087-
disambiguate(d, currentSignature, currentSymbol.erasedName)
2087+
disambiguate(d, currentSignature, currentSymbol.targetName)
20882088

20892089
private def disambiguate(d: Denotation, sig: Signature, target: Name)(using Context): Denotation =
20902090
if (sig != null)
@@ -2396,7 +2396,7 @@ object Types {
23962396
d = disambiguate(d,
23972397
if (lastSymbol.signature == Signature.NotAMethod) Signature.NotAMethod
23982398
else lastSymbol.asSeenFrom(prefix).signature,
2399-
lastSymbol.erasedName)
2399+
lastSymbol.targetName)
24002400
NamedType(prefix, name, d)
24012401
}
24022402
if (prefix eq this.prefix) this

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,14 @@ class TreePickler(pickler: TastyPickler) {
197197
if (sym.is(Flags.Private) || isShadowedRef) {
198198
writeByte(if (tpe.isType) TYPEREFin else TERMREFin)
199199
withLength {
200-
pickleNameAndSig(sym.name, sym.signature, sym.erasedName)
200+
pickleNameAndSig(sym.name, sym.signature, sym.targetName)
201201
pickleType(tpe.prefix)
202202
pickleType(sym.owner.typeRef)
203203
}
204204
}
205205
else {
206206
writeByte(if (tpe.isType) TYPEREF else TERMREF)
207-
pickleNameAndSig(sym.name, tpe.signature, sym.erasedName)
207+
pickleNameAndSig(sym.name, tpe.signature, sym.targetName)
208208
pickleType(tpe.prefix)
209209
}
210210
}
@@ -405,7 +405,7 @@ class TreePickler(pickler: TastyPickler) {
405405
}
406406
case _ =>
407407
val sig = tree.tpe.signature
408-
var ename = tree.symbol.erasedName
408+
var ename = tree.symbol.targetName
409409
val isAmbiguous =
410410
sig != Signature.NotAMethod
411411
&& qual.tpe.nonPrivateMember(name).match

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ import transform.SymUtils._
10861086
extends DeclarationMsg(OverridesNothingButNameExistsID) {
10871087
def msg =
10881088
val what =
1089-
if !existing.exists(sd => Denotations.targetNamesMatch(member.erasedName, sd.symbol.erasedName))
1089+
if !existing.exists(sd => Denotations.targetNamesMatch(member.targetName, sd.symbol.targetName))
10901090
then "target name"
10911091
else "signature"
10921092
em"""${member} has a different $what than the overridden declaration"""

compiler/src/dotty/tools/dotc/transform/Erasure.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class Erasure extends Phase with DenotTransformer {
7777
val oldOwner = ref.owner
7878
val newOwner = if (oldOwner eq defn.AnyClass) defn.ObjectClass else oldOwner
7979
val oldName = ref.name
80-
val newName = ref.erasedName
80+
val newName = ref.targetName
8181
val oldInfo = ref.info
8282
val newInfo = transformInfo(oldSymbol, oldInfo)
8383
val oldFlags = ref.flags
@@ -938,7 +938,7 @@ object Erasure {
938938
val origName = retainer.name.asTermName.exclude(BodyRetainerName)
939939
val targetName =
940940
if retainer.hasAnnotation(defn.TargetNameAnnot) then
941-
retainer.erasedName.unmangle(BodyRetainerName).exclude(BodyRetainerName)
941+
retainer.targetName.unmangle(BodyRetainerName).exclude(BodyRetainerName)
942942
else origName
943943
val inlineMeth = atPhase(typerPhase) {
944944
retainer.owner.info.decl(origName)

compiler/src/dotty/tools/dotc/transform/ResolveSuper.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ object ResolveSuper {
9191

9292
val (memberName, mix) = decomposeSuperName(acc.name.unexpandedName)
9393
val targetName =
94-
if acc.name == acc.erasedName then memberName
95-
else decomposeSuperName(acc.erasedName)._1
94+
if acc.name == acc.targetName then memberName
95+
else decomposeSuperName(acc.targetName)._1
9696

9797
report.debuglog(i"starting rebindsuper from $base of ${acc.showLocated}: ${acc.info} in $bcs, name = $memberName")
9898

@@ -112,7 +112,7 @@ object ResolveSuper {
112112

113113
bcs = bcs.tail
114114
}
115-
assert(sym.exists, i"cannot rebind $acc, ${acc.erasedName} $memberName")
115+
assert(sym.exists, i"cannot rebind $acc, ${acc.targetName} $memberName")
116116
sym
117117
}
118118
}

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,6 @@ object SymUtils:
266266
if original.hasAnnotation(defn.TargetNameAnnot) then
267267
self.addAnnotation(
268268
Annotation(defn.TargetNameAnnot,
269-
Literal(Constant(nameFn(original.erasedName).toString)).withSpan(original.span)))
269+
Literal(Constant(nameFn(original.targetName).toString)).withSpan(original.span)))
270270
end extension
271271
end SymUtils

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,12 +1208,12 @@ trait Checking {
12081208
var seen = Set[Name]()
12091209
for stat <- stats do
12101210
val sym = stat.symbol
1211-
val ename = sym.erasedName
1212-
if ename != sym.name then
1213-
val preExisting = ctx.effectiveScope.lookup(ename)
1214-
if preExisting.exists || seen.contains(ename) then
1215-
report.error(em"@targetName annotation ${'"'}$ename${'"'} clashes with other definition in same scope", stat.srcPos)
1216-
if stat.isDef then seen += ename
1211+
val tname = sym.targetName
1212+
if tname != sym.name then
1213+
val preExisting = ctx.effectiveScope.lookup(tname)
1214+
if preExisting.exists || seen.contains(tname) then
1215+
report.error(em"@targetName annotation ${'"'}$tname${'"'} clashes with other definition in same scope", stat.srcPos)
1216+
if stat.isDef then seen += tname
12171217
}
12181218

12191219
trait ReChecking extends Checking {

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ class Namer { typer: Typer =>
12981298
else NoType
12991299
}
13001300
val iRawInfo =
1301-
cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.erasedName).info
1301+
cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.targetName).info
13021302
val iResType = instantiatedResType(iRawInfo, typeParams, paramss).asSeenFrom(site, cls)
13031303
if (iResType.exists)
13041304
typr.println(i"using inherited type for ${mdef.name}; raw: $iRawInfo, inherited: $iResType")

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ object RefChecks {
431431
else if (!compatibleTypes(memberTp(self), otherTp(self)) &&
432432
!compatibleTypes(memberTp(upwardsSelf), otherTp(upwardsSelf)))
433433
overrideError("has incompatible type" + err.whyNoMatchStr(memberTp(self), otherTp(self)))
434-
else if (member.erasedName != other.erasedName)
435-
if (other.erasedName != other.name)
436-
overrideError(i"needs to be declared with @targetName(${"\""}${other.erasedName}${"\""}) so that external names match")
434+
else if (member.targetName != other.targetName)
435+
if (other.targetName != other.name)
436+
overrideError(i"needs to be declared with @targetName(${"\""}${other.targetName}${"\""}) so that external names match")
437437
else
438438
overrideError("cannot have a @targetName annotation since external names would be different")
439439
else

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,8 +1979,7 @@ class Typer extends Namer
19791979
PrepareInlineable.registerInlineInfo(sym, rhsToInline)
19801980

19811981
if (sym.isConstructor && !sym.isPrimaryConstructor) {
1982-
val ename = sym.erasedName
1983-
if (ename != sym.name)
1982+
if (sym.targetName != sym.name)
19841983
report.error(em"@targetName annotation may not be used on a constructor", ddef.srcPos)
19851984

19861985
for (param <- tparams1 ::: vparamss1.flatten)

0 commit comments

Comments
 (0)