summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-01-05 14:26:01 -0800
committerPaul Phillips <paulp@improving.org>2012-01-05 15:25:58 -0800
commit020053c3215579e8aeb871a4ad0078516994270d (patch)
tree447f518a7361a9a49993a22012b37a5c653e6284 /src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
parent749b476beca481b48cad8ea3810865634a010686 (diff)
downloadscala-020053c3215579e8aeb871a4ad0078516994270d.tar.gz
scala-020053c3215579e8aeb871a4ad0078516994270d.tar.bz2
scala-020053c3215579e8aeb871a4ad0078516994270d.zip
More consistent use of Names.
Several large helpings of tedium later, fewer strings are being discarded like so much refuse. Some names now cache a String, but only "named Names", so it's not very many and they pay for themselves pretty quickly. Many fewer name-related implicit conversions now taking place. A number of efficiency related measures.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 3d4f5e8724..92e4e257bf 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -39,10 +39,6 @@ trait SyntheticMethods extends ast.TreeDSL {
private object util {
private type CM[T] = ClassManifest[T]
- lazy val IteratorModule = getModule("scala.collection.Iterator")
- lazy val Iterator_apply = getMember(IteratorModule, nme.apply)
- def iteratorOfType(tp: Type) = appliedType(IteratorClass.typeConstructor, List(tp))
-
def ValOrDefDef(sym: Symbol, body: Tree) =
if (sym.isLazy) ValDef(sym, body)
else DefDef(sym, body)
@@ -76,11 +72,11 @@ trait SyntheticMethods extends ast.TreeDSL {
}
def manifestToSymbol(m: CM[_]): Symbol = m match {
- case x: scala.reflect.AnyValManifest[_] => definitions.getClass("scala." + x)
+ case x: scala.reflect.AnyValManifest[_] => getMember(ScalaPackageClass, newTermName("" + x))
case _ => getClassIfDefined(m.erasure.getName)
}
def companionType[T](implicit m: CM[T]) =
- getModule(m.erasure.getName).tpe
+ getRequiredModule(m.erasure.getName).tpe
// Use these like `applyType[List, Int]` or `applyType[Map, Int, String]`
def applyType[M](implicit m1: CM[M]): Type =
@@ -202,7 +198,7 @@ trait SyntheticMethods extends ast.TreeDSL {
// in the original order.
def accessors = clazz.caseFieldAccessors sortBy { acc =>
originalAccessors indexWhere { orig =>
- (acc.name == orig.name) || (acc.name startsWith (orig.name + "$").toTermName)
+ (acc.name == orig.name) || (acc.name startsWith (orig.name append "$"))
}
}
val arity = accessors.size
@@ -225,7 +221,7 @@ trait SyntheticMethods extends ast.TreeDSL {
)
def forwardToRuntime(method: Symbol): Tree =
- forwardMethod(method, getMember(ScalaRunTimeModule, "_" + method.name toTermName))(This(clazz) :: _)
+ forwardMethod(method, getMember(ScalaRunTimeModule, method.name prepend "_"))(This(clazz) :: _)
// Any member, including private
def hasConcreteImpl(name: Name) =
@@ -238,14 +234,14 @@ trait SyntheticMethods extends ast.TreeDSL {
}
}
def readConstantValue[T](name: String, default: T = null.asInstanceOf[T]): T = {
- clazzMember(name.toTermName).info match {
+ clazzMember(newTermName(name)).info match {
case NullaryMethodType(ConstantType(Constant(value))) => value.asInstanceOf[T]
case _ => default
}
}
def productIteratorMethod = {
createMethod(nme.productIterator, iteratorOfType(accessorLub))(_ =>
- gen.mkMethodCall(ScalaRunTimeModule, "typedProductIterator", List(accessorLub), List(This(clazz)))
+ gen.mkMethodCall(ScalaRunTimeModule, nme.typedProductIterator, List(accessorLub), List(This(clazz)))
)
}
def projectionMethod(accessor: Symbol, num: Int) = {