Skip to content

Commit b63af84

Browse files
committed
Drop choice of separator in expanded name.
It's not used and is too low-level anyway. Expanded names should be a semantic concept, the choice of separator is irrelevant.
1 parent 928aa20 commit b63af84

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

src/dotty/tools/dotc/core/NameOps.scala

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,17 @@ object NameOps {
149149

150150
/** The expanded name of `name` relative to this class `base` with given `separator`
151151
*/
152-
def expandedName(base: Symbol, separator: Name = nme.EXPAND_SEPARATOR)(implicit ctx: Context): N = {
153-
val prefix = if (base is Flags.ExpandedName) base.name else base.fullNameSeparated('$')
154-
name.fromName(prefix ++ separator ++ name).asInstanceOf[N]
155-
}
152+
def expandedName(base: Symbol)(implicit ctx: Context): N =
153+
expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated('$'))
154+
155+
/** The expanded name of `name` relative to `basename` with given `separator`
156+
*/
157+
def expandedName(prefix: Name)(implicit ctx: Context): N =
158+
name.fromName(prefix ++ nme.EXPAND_SEPARATOR ++ name).asInstanceOf[N]
156159

157-
def unexpandedName(separator: Name = nme.EXPAND_SEPARATOR): N = {
158-
val idx = name.lastIndexOfSlice(separator)
159-
if (idx < 0) name else (name drop (idx + separator.length)).asInstanceOf[N]
160+
def unexpandedName: N = {
161+
val idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR)
162+
if (idx < 0) name else (name drop (idx + nme.EXPAND_SEPARATOR.length)).asInstanceOf[N]
160163
}
161164

162165
def shadowedName: N = likeTyped(nme.SHADOWED ++ name)
@@ -289,11 +292,11 @@ object NameOps {
289292

290293
/** The name of an accessor for protected symbols. */
291294
def protectedAccessorName: TermName =
292-
PROTECTED_PREFIX ++ name.unexpandedName()
295+
PROTECTED_PREFIX ++ name.unexpandedName
293296

294297
/** The name of a setter for protected symbols. Used for inherited Java fields. */
295298
def protectedSetterName: TermName =
296-
PROTECTED_SET_PREFIX ++ name.unexpandedName()
299+
PROTECTED_SET_PREFIX ++ name.unexpandedName
297300

298301
def moduleVarName: TermName =
299302
name ++ MODULE_VAR_SUFFIX

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ object SymDenotations {
271271
/** The name with which the denoting symbol was created */
272272
final def originalName(implicit ctx: Context) = {
273273
val d = initial.asSymDenotation
274-
if (d is ExpandedName) d.name.unexpandedName() else d.name // !!!DEBUG, was: effectiveName
274+
if (d is ExpandedName) d.name.unexpandedName else d.name // !!!DEBUG, was: effectiveName
275275
}
276276

277277
/** The encoded full path name of this denotation, where outer names and inner names

src/dotty/tools/dotc/core/pickling/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class ClassfileParser(
139139
var sym = classRoot.owner
140140
while (sym.isClass && !(sym is Flags.ModuleClass)) {
141141
for (tparam <- sym.typeParams) {
142-
classTParams = classTParams.updated(tparam.name.unexpandedName(), tparam)
142+
classTParams = classTParams.updated(tparam.name.unexpandedName, tparam)
143143
}
144144
sym = sym.owner
145145
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
8484
if (!tsym.exists) super.refinementNameString(tp)
8585
else {
8686
val name = tsym.originalName
87-
nameString(if (tsym is ExpandedTypeParam) name.asTypeName.unexpandedName() else name)
87+
nameString(if (tsym is ExpandedTypeParam) name.asTypeName.unexpandedName else name)
8888
}
8989
}
9090

@@ -511,7 +511,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
511511
if (tree.exists(!_.isEmpty)) encl(blockText(tree)) else ""
512512

513513
override protected def polyParamName(name: TypeName): TypeName =
514-
name.unexpandedName()
514+
name.unexpandedName
515515

516516
override protected def treatAsTypeParam(sym: Symbol): Boolean = sym is TypeParam
517517

src/dotty/tools/dotc/transform/FullParameterization.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ trait FullParameterization {
9292
case _ => (0, info)
9393
}
9494
val ctparams = if(abstractOverClass) clazz.typeParams else Nil
95-
val ctnames = ctparams.map(_.name.unexpandedName())
95+
val ctnames = ctparams.map(_.name.unexpandedName)
9696

9797
/** The method result type */
9898
def resultType(mapClassParams: Type => Type) = {

0 commit comments

Comments
 (0)