diff options
author | Martin Odersky <odersky@gmail.com> | 2015-03-08 12:42:01 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:15:48 +0100 |
commit | 53a123064ffe437edc3d9e2f17530d3ce4e2b064 (patch) | |
tree | fe6ff2651a30a413a991998f6ae1cdd06d4c9c34 | |
parent | d572ec04a29d4bb70dccd5b01e205233d496d24d (diff) | |
download | dotty-53a123064ffe437edc3d9e2f17530d3ce4e2b064.tar.gz dotty-53a123064ffe437edc3d9e2f17530d3ce4e2b064.tar.bz2 dotty-53a123064ffe437edc3d9e2f17530d3ce4e2b064.zip |
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.
5 files changed, 17 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala index a003b4329..60e429bb3 100644 --- a/src/dotty/tools/dotc/core/NameOps.scala +++ b/src/dotty/tools/dotc/core/NameOps.scala @@ -149,14 +149,17 @@ object NameOps { /** The expanded name of `name` relative to this class `base` with given `separator` */ - def expandedName(base: Symbol, separator: Name = nme.EXPAND_SEPARATOR)(implicit ctx: Context): N = { - val prefix = if (base is Flags.ExpandedName) base.name else base.fullNameSeparated('$') - name.fromName(prefix ++ separator ++ name).asInstanceOf[N] - } + def expandedName(base: Symbol)(implicit ctx: Context): N = + expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated('$')) + + /** The expanded name of `name` relative to `basename` with given `separator` + */ + def expandedName(prefix: Name)(implicit ctx: Context): N = + name.fromName(prefix ++ nme.EXPAND_SEPARATOR ++ name).asInstanceOf[N] - def unexpandedName(separator: Name = nme.EXPAND_SEPARATOR): N = { - val idx = name.lastIndexOfSlice(separator) - if (idx < 0) name else (name drop (idx + separator.length)).asInstanceOf[N] + def unexpandedName: N = { + val idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR) + if (idx < 0) name else (name drop (idx + nme.EXPAND_SEPARATOR.length)).asInstanceOf[N] } def shadowedName: N = likeTyped(nme.SHADOWED ++ name) @@ -289,11 +292,11 @@ object NameOps { /** The name of an accessor for protected symbols. */ def protectedAccessorName: TermName = - PROTECTED_PREFIX ++ name.unexpandedName() + PROTECTED_PREFIX ++ name.unexpandedName /** The name of a setter for protected symbols. Used for inherited Java fields. */ def protectedSetterName: TermName = - PROTECTED_SET_PREFIX ++ name.unexpandedName() + PROTECTED_SET_PREFIX ++ name.unexpandedName def moduleVarName: TermName = name ++ MODULE_VAR_SUFFIX diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 4ededf796..44629c036 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -271,7 +271,7 @@ object SymDenotations { /** The name with which the denoting symbol was created */ final def originalName(implicit ctx: Context) = { val d = initial.asSymDenotation - if (d is ExpandedName) d.name.unexpandedName() else d.name // !!!DEBUG, was: effectiveName + if (d is ExpandedName) d.name.unexpandedName else d.name // !!!DEBUG, was: effectiveName } /** The encoded full path name of this denotation, where outer names and inner names diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index ed3eb7251..3b8daab39 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -139,7 +139,7 @@ class ClassfileParser( var sym = classRoot.owner while (sym.isClass && !(sym is Flags.ModuleClass)) { for (tparam <- sym.typeParams) { - classTParams = classTParams.updated(tparam.name.unexpandedName(), tparam) + classTParams = classTParams.updated(tparam.name.unexpandedName, tparam) } sym = sym.owner } diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 513d2c3c5..9b2d30fdf 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -84,7 +84,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (!tsym.exists) super.refinementNameString(tp) else { val name = tsym.originalName - nameString(if (tsym is ExpandedTypeParam) name.asTypeName.unexpandedName() else name) + nameString(if (tsym is ExpandedTypeParam) name.asTypeName.unexpandedName else name) } } @@ -511,7 +511,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (tree.exists(!_.isEmpty)) encl(blockText(tree)) else "" override protected def polyParamName(name: TypeName): TypeName = - name.unexpandedName() + name.unexpandedName override protected def treatAsTypeParam(sym: Symbol): Boolean = sym is TypeParam diff --git a/src/dotty/tools/dotc/transform/FullParameterization.scala b/src/dotty/tools/dotc/transform/FullParameterization.scala index 1fc9591d2..2e3015275 100644 --- a/src/dotty/tools/dotc/transform/FullParameterization.scala +++ b/src/dotty/tools/dotc/transform/FullParameterization.scala @@ -92,7 +92,7 @@ trait FullParameterization { case _ => (0, info) } val ctparams = if(abstractOverClass) clazz.typeParams else Nil - val ctnames = ctparams.map(_.name.unexpandedName()) + val ctnames = ctparams.map(_.name.unexpandedName) /** The method result type */ def resultType(mapClassParams: Type => Type) = { |