Skip to content

Commit 7b94028

Browse files
committed
New NameOps methods for Scala2 traits
Also: generalize expandedName so that it can cater for trait setters.
1 parent 6c9291d commit 7b94028

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,17 @@ object NameOps {
155155

156156
/** The expanded name of `name` relative to given class `base`.
157157
*/
158-
def expandedName(base: Symbol)(implicit ctx: Context): N =
159-
expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated("$"))
158+
def expandedName(base: Symbol, separator: Name)(implicit ctx: Context): N =
159+
expandedName(if (base is Flags.ExpandedName) base.name else base.fullNameSeparated("$"), separator)
160+
161+
def expandedName(base: Symbol)(implicit ctx: Context): N = expandedName(base, nme.EXPAND_SEPARATOR)
160162

161163
/** The expanded name of `name` relative to `basename` with given `separator`
162164
*/
163-
def expandedName(prefix: Name): N =
164-
name.fromName(prefix ++ nme.EXPAND_SEPARATOR ++ name).asInstanceOf[N]
165+
def expandedName(prefix: Name, separator: Name = nme.EXPAND_SEPARATOR): N =
166+
name.fromName(prefix ++ separator ++ name).asInstanceOf[N]
167+
168+
def expandedName(prefix: Name): N = expandedName(prefix, nme.EXPAND_SEPARATOR)
165169

166170
def unexpandedName: N = {
167171
val idx = name.lastIndexOfSlice(nme.EXPAND_SEPARATOR)
@@ -178,6 +182,8 @@ object NameOps {
178182

179183
def revertShadowed: N = likeTyped(name.drop(nme.SHADOWED.length))
180184

185+
def implClassName: N = likeTyped(name ++ tpnme.IMPL_CLASS_SUFFIX)
186+
181187
/** Translate a name into a list of simple TypeNames and TermNames.
182188
* In all segments before the last, type/term is determined by whether
183189
* the following separator char is '.' or '#'. The last segment

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ object StdNames {
126126
val INITIALIZER_PREFIX: N = "initial$"
127127
val COMPANION_MODULE_METHOD: N = "companion$module"
128128
val COMPANION_CLASS_METHOD: N = "companion$class"
129+
val TRAIT_SETTER_SEPARATOR: N = "$_setter_$"
129130

130131
// value types (and AnyRef) are all used as terms as well
131132
// as (at least) arguments to the @specialize annotation.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ trait FullParameterization {
8686
* }
8787
*
8888
* If a self type is present, $this has this self type as its type.
89+
* @param abstractOverClass if true, include the type parameters of the class in the method's list of type parameters.
8990
*/
9091
def fullyParameterizedType(info: Type, clazz: ClassSymbol, abstractOverClass: Boolean = true)(implicit ctx: Context): Type = {
9192
val (mtparamCount, origResult) = info match {

0 commit comments

Comments
 (0)