diff options
author | Paul Phillips <paulp@improving.org> | 2012-11-30 16:23:11 +0100 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-01 09:31:13 +0100 |
commit | 47245f547f55df1feff9add1e8cd73edd8d0b154 (patch) | |
tree | 0bad23966dfaa8a7258b2d73a40a3a78658dc0ec /src/reflect | |
parent | 08e717eaee731456a51adb08f72aa5d9f083a29a (diff) | |
download | scala-47245f547f55df1feff9add1e8cd73edd8d0b154.tar.gz scala-47245f547f55df1feff9add1e8cd73edd8d0b154.tar.bz2 scala-47245f547f55df1feff9add1e8cd73edd8d0b154.zip |
Remove Name -> TermName implicit.
And simplify the name implicits.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Names.scala | 21 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 2 |
2 files changed, 6 insertions, 17 deletions
diff --git a/src/reflect/scala/reflect/internal/Names.scala b/src/reflect/scala/reflect/internal/Names.scala index 333651162e..cea9215ae2 100644 --- a/src/reflect/scala/reflect/internal/Names.scala +++ b/src/reflect/scala/reflect/internal/Names.scala @@ -10,22 +10,7 @@ import scala.io.Codec import java.security.MessageDigest import scala.language.implicitConversions -trait LowPriorityNames { - self: Names => - - implicit def nameToNameOps(name: Name): NameOps[Name] = new NameOps[Name](name) -} - -/** The class Names ... - * - * @author Martin Odersky - * @version 1.0, 05/02/2005 - */ -trait Names extends api.Names with LowPriorityNames { - implicit def promoteTermNamesAsNecessary(name: Name): TermName = name.toTermName - -// Operations ------------------------------------------------------------- - +trait Names extends api.Names { private final val HASH_SIZE = 0x8000 private final val HASH_MASK = 0x7FFF private final val NAME_SIZE = 0x20000 @@ -399,9 +384,13 @@ trait Names extends api.Names with LowPriorityNames { def debugString = { val s = decode ; if (isTypeName) s + "!" else s } } + implicit def AnyNameOps(name: Name): NameOps[Name] = new NameOps(name) implicit def TermNameOps(name: TermName): NameOps[TermName] = new NameOps(name) implicit def TypeNameOps(name: TypeName): NameOps[TypeName] = new NameOps(name) + /** FIXME: This is a good example of something which is pure "value class" but cannot + * reap the benefits because an (unused) $outer pointer so it is not single-field. + */ final class NameOps[T <: Name](name: T) { def stripSuffix(suffix: Name): T = if (name endsWith suffix) dropRight(suffix.length) else name def dropRight(n: Int): T = name.subName(0, name.length - n).asInstanceOf[T] diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index ad7dbe5ef1..ebe1762190 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -248,7 +248,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def newModuleAndClassSymbol(name: Name, pos: Position, flags0: FlagSet): (ModuleSymbol, ClassSymbol) = { val flags = flags0 | MODULE - val m = newModuleSymbol(name, pos, flags) + val m = newModuleSymbol(name.toTermName, pos, flags) val c = newModuleClass(name.toTypeName, pos, flags & ModuleToClassFlags) connectModuleToClass(m, c) (m, c) |