From 11848a8c620be514ea43ea4383ca2b91a1aa8627 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 29 May 2015 11:09:15 +0200 Subject: New NameOps methods for Scala2 traits Also: generalize expandedName so that it can cater for trait setters. --- src/dotty/tools/dotc/core/NameOps.scala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/core/NameOps.scala') diff --git a/src/dotty/tools/dotc/core/NameOps.scala b/src/dotty/tools/dotc/core/NameOps.scala index bf5e219cf..dc94f6db1 100644 --- a/src/dotty/tools/dotc/core/NameOps.scala +++ b/src/dotty/tools/dotc/core/NameOps.scala @@ -155,13 +155,17 @@ object NameOps { /** The expanded name of `name` relative to given class `base`. */ - def expandedName(base: Symbol)(implicit ctx: Context): N = - expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated("$")) + def expandedName(base: Symbol, separator: Name)(implicit ctx: Context): N = + expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated("$"), separator) + + def expandedName(base: Symbol)(implicit ctx: Context): N = expandedName(base, nme.EXPAND_SEPARATOR) /** The expanded name of `name` relative to `basename` with given `separator` */ - def expandedName(prefix: Name): N = - name.fromName(prefix ++ nme.EXPAND_SEPARATOR ++ name).asInstanceOf[N] + def expandedName(prefix: Name, separator: Name = nme.EXPAND_SEPARATOR): N = + name.fromName(prefix ++ separator ++ name).asInstanceOf[N] + + def expandedName(prefix: Name): N = expandedName(prefix, nme.EXPAND_SEPARATOR) def unexpandedName: N = { val idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR) @@ -178,6 +182,8 @@ object NameOps { def revertShadowed: N = likeTyped(name.drop(nme.SHADOWED.length)) + def implClassName: N = likeTyped(name ++ tpnme.IMPL_CLASS_SUFFIX) + /** 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 -- cgit v1.2.3