diff options
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/NameOps.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala index 4d6cca61d..dc90a8d3b 100644 --- a/src/dotty/tools/dotc/core/NameOps.scala +++ b/src/dotty/tools/dotc/core/NameOps.scala @@ -6,7 +6,7 @@ import scala.annotation.switch import scala.io.Codec import Names._, StdNames._, Contexts._, Symbols._, Flags._ import Decorators.StringDecorator -import dotty.tools.dotc.util.Chars +import util.{Chars, NameTransformer} import Chars.isOperatorPart object NameOps { @@ -59,7 +59,7 @@ object NameOps { implicit class NameDecorator[N <: Name](val name: N) extends AnyVal { import nme._ - def likeTyped(n: Name): N = + def likeTyped(n: PreName): N = (if (name.isTermName) n.toTermName else n.toTypeName).asInstanceOf[N] def isConstructorName = name == CONSTRUCTOR || name == TRAIT_CONSTRUCTOR @@ -184,6 +184,11 @@ object NameOps { def implClassName: N = likeTyped(name ++ tpnme.IMPL_CLASS_SUFFIX) + def freshened(implicit ctx: Context): N = + likeTyped( + if (name.isModuleClassName) name.stripModuleClassSuffix.freshened.moduleClassName + else likeTyped(ctx.freshName(name ++ NameTransformer.NAME_JOIN_STRING))) + /** Translate a name into a list of simple TypeNames and TermNames. * In all segments before the last, type/term is determined by whether * the following separator char is '.' or '#'. The last segment |