diff options
author | Paul Phillips <paulp@improving.org> | 2012-12-01 12:38:10 +0100 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-02 13:39:05 -0800 |
commit | de6649439e39c1f656644ac090fc49a7a8f02340 (patch) | |
tree | 25639987d8bf130ee570269fc50f285240ccecf6 /src/reflect | |
parent | 47245f547f55df1feff9add1e8cd73edd8d0b154 (diff) | |
download | scala-de6649439e39c1f656644ac090fc49a7a8f02340.tar.gz scala-de6649439e39c1f656644ac090fc49a7a8f02340.tar.bz2 scala-de6649439e39c1f656644ac090fc49a7a8f02340.zip |
Remove TermName -> String implicit.
These implicits were crutches going back to a much Stringier
time. Of course "with great type safety comes great verbosity"
and no doubt this could be cleaned up significantly further.
At least the underpinnings are consistent now - the only
implicits involving name should be String -> TypeName and
String -> TermName.
Diffstat (limited to 'src/reflect')
4 files changed, 17 insertions, 18 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 9a846179b9..37c61735d6 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -14,7 +14,7 @@ import scala.reflect.api.{Universe => ApiUniverse} trait Definitions extends api.StandardDefinitions { self: SymbolTable => - import rootMirror.{getModule, getClassByName, getRequiredClass, getRequiredModule, getRequiredPackage, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageObjectIfDefined, requiredClass, requiredModule} + import rootMirror.{getModule, getPackage, getClassByName, getRequiredClass, getRequiredModule, getClassIfDefined, getModuleIfDefined, getPackageObject, getPackageObjectIfDefined, requiredClass, requiredModule} object definitions extends DefinitionsClass @@ -169,11 +169,11 @@ trait Definitions extends api.StandardDefinitions { // It becomes tricky to create dedicated objects for other symbols because // of initialization order issues. - lazy val JavaLangPackage = getRequiredPackage(sn.JavaLang) + lazy val JavaLangPackage = getPackage("java.lang") lazy val JavaLangPackageClass = JavaLangPackage.moduleClass.asClass - lazy val ScalaPackage = getRequiredPackage(nme.scala_) + lazy val ScalaPackage = getPackage("scala") lazy val ScalaPackageClass = ScalaPackage.moduleClass.asClass - lazy val RuntimePackage = getRequiredPackage("scala.runtime") + lazy val RuntimePackage = getPackage("scala.runtime") lazy val RuntimePackageClass = RuntimePackage.moduleClass.asClass // convenient one-argument parameter lists diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index 80aa06d020..6e76a7afb3 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -172,14 +172,15 @@ trait Mirrors extends api.Mirrors { case _ => MissingRequirementError.notFound("package " + fullname) } - def getPackage(fullname: Name): ModuleSymbol = + def getPackage(fullname: TermName): ModuleSymbol = ensurePackageSymbol(fullname.toString, getModuleOrClass(fullname), allowModules = true) - def getRequiredPackage(fullname: String): ModuleSymbol = + @deprecated("Use getPackage", "2.11.0") def getRequiredPackage(fullname: String): ModuleSymbol = getPackage(newTermNameCached(fullname)) - def getPackageObject(fullname: String): ModuleSymbol = - (getPackage(newTermName(fullname)).info member nme.PACKAGE) match { + def getPackageObject(fullname: String): ModuleSymbol = getPackageObject(newTermName(fullname)) + def getPackageObject(fullname: TermName): ModuleSymbol = + (getPackage(fullname).info member nme.PACKAGE) match { case x: ModuleSymbol => x case _ => MissingRequirementError.notFound("package object " + fullname) } @@ -187,8 +188,8 @@ trait Mirrors extends api.Mirrors { def getPackageObjectIfDefined(fullname: String): Symbol = getPackageObjectIfDefined(newTermNameCached(fullname)) - def getPackageObjectIfDefined(fullname: Name): Symbol = - wrapMissing(getPackageObject(fullname.toTermName)) + def getPackageObjectIfDefined(fullname: TermName): Symbol = + wrapMissing(getPackageObject(fullname)) override def staticPackage(fullname: String): ModuleSymbol = ensurePackageSymbol(fullname.toString, getModuleOrClass(newTermNameCached(fullname)), allowModules = false) diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index a5810c9c83..a1e8ada302 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -18,8 +18,6 @@ trait StdNames { def encode(str: String): TermName = newTermNameCached(NameTransformer.encode(str)) - implicit def lowerTermNames(n: TermName): String = n.toString - /** Tensions: would like the keywords to be the very first names entered into the names * storage so their ids count from 0, which simplifies the parser. Switched to abstract * classes to avoid all the indirection which is generated with implementation-containing @@ -37,11 +35,7 @@ trait StdNames { kws = kws + result result } - def result: Set[TermName] = { - val result = kws - kws = null - result - } + def result: Set[TermName] = try kws finally kws = null } private final object compactify extends (String => String) { @@ -201,6 +195,8 @@ trait StdNames { } abstract class TypeNames extends Keywords with TypeNamesApi { + override type NameType = TypeName + protected implicit def createNameType(name: String): TypeName = newTypeNameCached(name) final val BYNAME_PARAM_CLASS_NAME: NameType = "<byname>" @@ -262,6 +258,8 @@ trait StdNames { } abstract class TermNames extends Keywords with TermNamesApi { + override type NameType = TermName + protected implicit def createNameType(name: String): TermName = newTermNameCached(name) /** Base strings from which synthetic names are derived. */ diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index d264cc06b4..8819cd058d 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -466,7 +466,7 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni staticSingletonInstance(classLoader, symbol.fullName) else if (outer == null) staticSingletonInstance(classToJava(symbol.moduleClass.asClass)) - else innerSingletonInstance(outer, symbol.name) + else innerSingletonInstance(outer, symbol.name.toString) } override def toString = s"module mirror for ${symbol.fullName} (bound to $outer)" } |