Skip to content

Commit c2f2962

Browse files
committed
Rename Symbol#name to symName
This is to avoid polymorphic dispatch on name once Symbols are subtypes of SymDenotations
1 parent 8d26352 commit c2f2962

24 files changed

+35
-35
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
661661
*/
662662
private def makeStatifiedDefDef(dd: DefDef): DefDef =
663663
val origSym = dd.symbol.asTerm
664-
val newSym = makeStatifiedDefSymbol(origSym, origSym.name)
664+
val newSym = makeStatifiedDefSymbol(origSym, origSym.symName)
665665
tpd.DefDef(newSym, { paramRefss =>
666666
val selfParamRef :: regularParamRefs = paramRefss.head
667667
val enclosingClass = origSym.owner.asClass

compiler/src/dotty/tools/backend/sjs/JSDefinitions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ final class JSDefinitions()(using Context) {
236236

237237
/** If `cls` is a class in the scala package, its name, otherwise EmptyTypeName */
238238
private def scalajsClassName(cls: Symbol)(using Context): TypeName =
239-
if (cls.isClass && cls.owner == ScalaJSJSPackageClass) cls.asClass.name
239+
if (cls.isClass && cls.owner == ScalaJSJSPackageClass) cls.name.asTypeName
240240
else EmptyTypeName
241241

242242
/** Is the given `cls` a class of the form `scala.scalajs.js.prefixN` where

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ object desugar {
133133
/** A derived type definition watching `sym` */
134134
def derivedTypeParamWithVariance(sym: TypeSymbol)(using Context): TypeDef =
135135
val variance = VarianceFlags & sym.flags
136-
TypeDef(sym.name, DerivedFromParamTree().watching(sym)).withFlags(TypeParam | Synthetic | variance)
136+
TypeDef(sym.symName, DerivedFromParamTree().watching(sym)).withFlags(TypeParam | Synthetic | variance)
137137

138138
/** A value definition copied from `vdef` with a tpt typetree derived from it */
139139
def derivedTermParam(vdef: ValDef)(using Context): ValDef =

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
201201
}
202202

203203
def ValDef(sym: TermSymbol, rhs: LazyTree = EmptyTree)(using Context): ValDef =
204-
ta.assignType(untpd.ValDef(sym.name, TypeTree(sym.info), rhs), sym)
204+
ta.assignType(untpd.ValDef(sym.symName, TypeTree(sym.info), rhs), sym)
205205

206206
def SyntheticValDef(name: TermName, rhs: Tree)(using Context): ValDef =
207207
ValDef(newSymbol(ctx.owner, name, Synthetic, rhs.tpe.widen, coord = rhs.span), rhs)
@@ -211,7 +211,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
211211
sym.setParamss(paramss)
212212
ta.assignType(
213213
untpd.DefDef(
214-
sym.name,
214+
sym.symName,
215215
paramss.map {
216216
case TypeSymbols(params) => params.map(param => TypeDef(param).withSpan(param.span))
217217
case TermSymbols(params) => params.map(param => ValDef(param).withSpan(param.span))
@@ -284,7 +284,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
284284
end DefDef
285285

286286
def TypeDef(sym: TypeSymbol)(using Context): TypeDef =
287-
ta.assignType(untpd.TypeDef(sym.name, TypeTree(sym.info)), sym)
287+
ta.assignType(untpd.TypeDef(sym.symName, TypeTree(sym.info)), sym)
288288

289289
def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree], superArgs: List[Tree] = Nil)(using Context): TypeDef = {
290290
val firstParent :: otherParents = cls.info.parents
@@ -320,7 +320,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
320320
.orElse(newLocalDummy(cls))
321321
val impl = untpd.Template(constr, parents, Nil, selfType, newTypeParams ++ body)
322322
.withType(localDummy.termRef)
323-
ta.assignType(untpd.TypeDef(cls.name, impl), cls)
323+
ta.assignType(untpd.TypeDef(cls.symName, impl), cls)
324324
}
325325

326326
/** An anonymous class

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ class Definitions {
16791679
def isValueSubType(tref1: TypeRef, tref2: TypeRef)(using Context): Boolean =
16801680
valueTypeEnc(tref2.name) % valueTypeEnc(tref1.name) == 0
16811681
def isValueSubClass(sym1: Symbol, sym2: Symbol): Boolean =
1682-
valueTypeEnc(sym2.asClass.name) % valueTypeEnc(sym1.asClass.name) == 0
1682+
valueTypeEnc(sym2.name.asTypeName) % valueTypeEnc(sym1.name.asTypeName) == 0
16831683

16841684
@tu lazy val specialErasure: SimpleIdentityMap[Symbol, ClassSymbol] =
16851685
SimpleIdentityMap.empty[Symbol]

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ object Symbols:
115115

116116
def isStatic(using Context): Boolean
117117

118-
def name(using Context): ThisName
118+
def symName(using Context): ThisName
119119
def signature(using Context): Signature
120120

121121
def span: Span
@@ -387,7 +387,7 @@ object Symbols:
387387
def filter(p: Symbol => Boolean): Symbol = if (p(this.fromSymbolImpl)) this.fromSymbolImpl else NoSymbol
388388

389389
/** The current name of this symbol */
390-
final def name(using Context): ThisName = denot.name.asInstanceOf[ThisName]
390+
final def symName(using Context): ThisName = denot.name.asInstanceOf[ThisName]
391391

392392
/** The source or class file from which this class or
393393
* the class containing this symbol was generated, null if not applicable.
@@ -471,7 +471,7 @@ object Symbols:
471471

472472
// ParamInfo types and methods
473473
def isTypeParam(using Context): Boolean = denot.is(TypeParam)
474-
def paramName(using Context): ThisName = name.asInstanceOf[ThisName]
474+
def paramName(using Context): ThisName = symName
475475
def paramInfo(using Context): Type = denot.info
476476
def paramInfoAsSeenFrom(pre: Type)(using Context): Type = pre.memberInfo(this.fromSymbolImpl)
477477
def paramInfoOrCompleter(using Context): Type = denot.infoOrCompleter
@@ -607,7 +607,7 @@ object Symbols:
607607
*/
608608
def copy(
609609
owner: Symbol = sym.owner,
610-
name: N = sym.name,
610+
name: N = sym.symName,
611611
flags: FlagSet = sym.flags,
612612
info: Type = sym.info,
613613
privateWithin: Symbol = sym.privateWithin,

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
736736

737737
private def Modifiers(sym: Symbol): Modifiers = untpd.Modifiers(
738738
sym.flags & (if (sym.isType) ModifierFlags | VarianceFlags else ModifierFlags),
739-
if (sym.privateWithin.exists) sym.privateWithin.asType.name else tpnme.EMPTY,
739+
if (sym.privateWithin.exists) sym.privateWithin.name.asTypeName else tpnme.EMPTY,
740740
sym.annotations.filterNot(ann => dropAnnotForModText(ann.symbol)).map(_.tree))
741741

742742
protected def dropAnnotForModText(sym: Symbol): Boolean = sym == defn.BodyAnnot

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ abstract class AccessProxies {
106106
case getterRef: RefTree =>
107107
val getter = getterRef.symbol.asTerm
108108
val accessed = accessedBy(getter)
109-
val setterName = getter.name.setterName
109+
val setterName = getter.symName.setterName
110110
def toSetterInfo(getterInfo: Type): Type = getterInfo match {
111111
case getterInfo: LambdaType =>
112112
getterInfo.derivedLambdaType(resType = toSetterInfo(getterInfo.resType))
@@ -134,7 +134,7 @@ abstract class AccessProxies {
134134
if (accessorClass.exists) {
135135
if accessorClass.is(Package) then
136136
accessorClass = ctx.owner.topLevelClass
137-
val accessorName = accessorNameKind(accessed.name)
137+
val accessorName = accessorNameKind(accessed.symName)
138138
val accessorInfo =
139139
accessed.info.ensureMethodic.asSeenFrom(accessorClass.thisType, accessed.owner)
140140
val accessor = accessorSymbol(accessorClass, accessorName, accessorInfo, accessed)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Constructors extends MiniPhase with IdentityDenotTransformer { thisPhase =
225225
if sym.setter.exists then
226226
sym.setter
227227
else
228-
val setterName = sym.asTerm.name.setterName
228+
val setterName = sym.name.asTermName.setterName
229229
sym.owner.info.decls.find(d => d.is(Accessor) && d.name == setterName)
230230
val setter =
231231
if (symSetter.exists) symSetter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ExpandSAMs extends MiniPhase:
5656
val tpe1 = checkRefinements(tpe, fn)
5757
val Seq(samDenot) = tpe1.possibleSamMethods
5858
cpy.Block(tree)(stats,
59-
AnonClass(tpe1 :: Nil, fn.symbol.asTerm :: Nil, samDenot.symbol.asTerm.name :: Nil))
59+
AnonClass(tpe1 :: Nil, fn.symbol.asTerm :: Nil, samDenot.symbol.name.asTermName :: Nil))
6060
}
6161
case _ =>
6262
tree

0 commit comments

Comments
 (0)