diff options
author | Paul Phillips <paulp@improving.org> | 2012-01-05 14:26:01 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-01-05 15:25:58 -0800 |
commit | 020053c3215579e8aeb871a4ad0078516994270d (patch) | |
tree | 447f518a7361a9a49993a22012b37a5c653e6284 /src/compiler/scala/tools/nsc | |
parent | 749b476beca481b48cad8ea3810865634a010686 (diff) | |
download | scala-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')
48 files changed, 332 insertions, 377 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index f9c818daf0..6a6379cca2 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -220,8 +220,8 @@ trait DocComments { self: Global => else site.info.baseClasses searchList collectFirst { case x if defs(x) contains vble => defs(x)(vble) } match { - case Some(str) if str startsWith '$' => lookupVariable(str.tail, site) - case res => res orElse lookupVariable(vble, site.owner) + case Some(str) if str startsWith "$" => lookupVariable(str.tail, site) + case res => res orElse lookupVariable(vble, site.owner) } } @@ -397,7 +397,7 @@ trait DocComments { self: Global => if (tpe != NoType) tpe else { val alias1 = alias.cloneSymbol(definitions.RootClass) - alias1.name = repl.toTypeName + alias1.name = newTypeName(repl) typeRef(NoPrefix, alias1, Nil) } case None => diff --git a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala index 752e3c6699..7b5de1f3dd 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeBrowsers.scala @@ -360,7 +360,7 @@ abstract class TreeBrowsers { ("Program", EMPTY) case UnitTree(unit) => - ("CompilationUnit", unit.toString) + ("CompilationUnit", newTermName("" + unit)) case DocDef(comment, definition) => ("DocDef", EMPTY) @@ -441,7 +441,7 @@ abstract class TreeBrowsers { ("Apply", EMPTY) case Super(qualif, mix) => - ("Super", "mix: " + mix) + ("Super", newTermName("mix: " + mix)) case This(qualifier) => ("This", qualifier) diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index 0dc3b1fffd..e69c463e71 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -128,7 +128,7 @@ abstract class TreeGen extends reflect.internal.TreeGen { def mkManifestFactoryCall(full: Boolean, constructor: String, tparg: Type, args: List[Tree]): Tree = mkMethodCall( if (full) FullManifestModule else PartialManifestModule, - constructor, + newTermName(constructor), List(tparg), args ) @@ -161,16 +161,10 @@ abstract class TreeGen extends reflect.internal.TreeGen { * apply the element type directly. */ def mkWrapArray(tree: Tree, elemtp: Type) = { - val sym = elemtp.typeSymbol - val meth: Name = - if (isValueClass(sym)) "wrap"+sym.name+"Array" - else if ((elemtp <:< AnyRefClass.tpe) && !isPhantomClass(sym)) "wrapRefArray" - else "genericWrapArray" - mkMethodCall( PredefModule, - meth, - if (isValueClass(sym)) Nil else List(elemtp), + wrapArrayMethodName(elemtp), + if (isScalaValueType(elemtp)) Nil else List(elemtp), List(tree) ) } @@ -179,8 +173,8 @@ abstract class TreeGen extends reflect.internal.TreeGen { * elem type elemtp to expected type pt. */ def mkCastArray(tree: Tree, elemtp: Type, pt: Type) = - if (elemtp.typeSymbol == AnyClass && isValueClass(tree.tpe.typeArgs.head.typeSymbol)) - mkCast(mkRuntimeCall("toObjectArray", List(tree)), pt) + if (elemtp.typeSymbol == AnyClass && isScalaValueType(tree.tpe.typeArgs.head)) + mkCast(mkRuntimeCall(nme.toObjectArray, List(tree)), pt) else mkCast(tree, pt) diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index db97dd3475..5881821ab3 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -314,7 +314,7 @@ self => val stmts = templateStatSeq(false)._2 accept(EOF) - def mainModuleName = settings.script.value + def mainModuleName = newTermName(settings.script.value) /** If there is only a single object template in the file and it has a * suitable main method, we will use it rather than building another object * around it. Since objects are loaded lazily the whole script would have @@ -343,7 +343,7 @@ self => * whole additional parse. So instead, if the actual object's name differs from * what the script is expecting, we transform it to match. */ - if (name.toString == mainModuleName) md + if (name == mainModuleName) md else treeCopy.ModuleDef(md, mods, mainModuleName, template) case _ => /** If we see anything but the above, fail. */ @@ -352,7 +352,7 @@ self => Some(makePackaging(0, emptyPkg, newStmts)) } - if (mainModuleName == ScriptRunner.defaultScriptMain) + if (mainModuleName == newTermName(ScriptRunner.defaultScriptMain)) searchForMain() foreach { return _ } /** Here we are building an AST representing the following source fiction, @@ -384,13 +384,13 @@ self => // def main def mainParamType = AppliedTypeTree(Ident(tpnme.Array), List(Ident(tpnme.String))) - def mainParameter = List(ValDef(Modifiers(Flags.PARAM), "argv", mainParamType, EmptyTree)) - def mainSetArgv = List(ValDef(NoMods, "args", TypeTree(), Ident("argv"))) + def mainParameter = List(ValDef(Modifiers(Flags.PARAM), nme.argv, mainParamType, EmptyTree)) + def mainSetArgv = List(ValDef(NoMods, nme.args, TypeTree(), Ident(nme.argv))) def mainNew = makeNew(Nil, emptyValDef, stmts, List(Nil), NoPosition, NoPosition) def mainDef = DefDef(NoMods, nme.main, Nil, List(mainParameter), scalaDot(tpnme.Unit), Block(mainSetArgv, mainNew)) // object Main - def moduleName = ScriptRunner scriptMain settings + def moduleName = newTermName(ScriptRunner scriptMain settings) def moduleBody = Template(List(scalaScalaObjectConstr), emptyValDef, List(emptyInit, mainDef)) def moduleDef = ModuleDef(NoMods, moduleName, moduleBody) @@ -980,6 +980,7 @@ self => nme.ERROR } def ident(): Name = ident(true) + def rawIdent(): Name = try in.name finally in.nextToken() /** For when it's known already to be a type name. */ def identForType(): TypeName = ident().toTypeName @@ -1117,7 +1118,7 @@ self => case LONGLIT => in.intVal(isNegated) case FLOATLIT => in.floatVal(isNegated).toFloat case DOUBLELIT => in.floatVal(isNegated) - case STRINGLIT => in.strVal + case STRINGLIT => in.strVal.intern() case TRUE => true case FALSE => false case NULL => null @@ -1465,8 +1466,9 @@ self => def prefixExpr(): Tree = { if (isUnaryOp) { atPos(in.offset) { - val name: Name = "unary_" + ident() - if (in.name == raw.MINUS && isNumericLit) simpleExprRest(atPos(in.offset)(literal(true)), true) + val name = nme.toUnaryName(rawIdent()) + // val name = nme.toUnaryName(ident()) // val name: Name = "unary_" + ident() + if (name == nme.UNARY_- && isNumericLit) simpleExprRest(atPos(in.offset)(literal(true)), true) else Select(stripParens(simpleExpr()), name) } } diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala index b8fa55447a..ffe65aec63 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala @@ -58,11 +58,11 @@ abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) { private object xmltypes extends XMLTypeNames { type NameType = TypeName - implicit def createNameType(name: String): TypeName = newTypeName(name) + implicit def createNameType(name: String): TypeName = newTypeNameCached(name) } private object xmlterms extends XMLTermNames { type NameType = TermName - implicit def createNameType(name: String): TermName = newTermName(name) + implicit def createNameType(name: String): TermName = newTermNameCached(name) } import xmltypes.{_Comment, _Elem, _EntityRef, _Group, _MetaData, _NamespaceBinding, _NodeBuffer, diff --git a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala index d80a1c4f34..27df45b563 100644 --- a/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala +++ b/src/compiler/scala/tools/nsc/backend/JavaPlatform.scala @@ -39,9 +39,9 @@ trait JavaPlatform extends Platform { ) ++ depAnalysisPhase lazy val externalEquals = getMember(BoxesRunTimeClass, nme.equals_) - lazy val externalEqualsNumNum = getMember(BoxesRunTimeClass, "equalsNumNum") - lazy val externalEqualsNumChar = getMember(BoxesRunTimeClass, "equalsNumChar") - lazy val externalEqualsNumObject = getMember(BoxesRunTimeClass, "equalsNumObject") + lazy val externalEqualsNumNum = getMember(BoxesRunTimeClass, nme.equalsNumNum) + lazy val externalEqualsNumChar = getMember(BoxesRunTimeClass, nme.equalsNumChar) + lazy val externalEqualsNumObject = getMember(BoxesRunTimeClass, nme.equalsNumObject) /** We could get away with excluding BoxedBooleanClass for the * purpose of equality testing since it need not compare equal diff --git a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala index 1880bdc52c..ffc6640743 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/ExceptionHandlers.scala @@ -3,13 +3,11 @@ * @author Martin Odersky */ - package scala.tools.nsc package backend package icode -import scala.collection.{ mutable, immutable, generic } -import util.{ Position, NoPosition } +import scala.collection.{ mutable, immutable } /** * Exception handlers are pieces of code that `handle` exceptions on @@ -21,10 +19,10 @@ import util.{ Position, NoPosition } trait ExceptionHandlers { self: ICodes => - import global.{ definitions, Symbol, NoSymbol } + import global._ import definitions.{ ThrowableClass } - class ExceptionHandler(val method: IMethod, val label: String, val cls: Symbol, val pos: Position) { + class ExceptionHandler(val method: IMethod, val label: TermName, val cls: Symbol, val pos: Position) { def loadExceptionClass = if (cls == NoSymbol) ThrowableClass else cls private var _startBlock: BasicBlock = _; var finalizer: Finalizer = _; @@ -69,12 +67,12 @@ trait ExceptionHandlers { def dup: ExceptionHandler = new ExceptionHandler(this) } - class Finalizer(method: IMethod, label: String, pos: Position) extends ExceptionHandler(method, label, NoSymbol, pos) { + class Finalizer(method: IMethod, label: TermName, pos: Position) extends ExceptionHandler(method, label, NoSymbol, pos) { override def toString() = "finalizer_" + label override def dup: Finalizer = new Finalizer(method, label, pos) } - object NoFinalizer extends Finalizer(null, "<no finalizer>", NoPosition) { + object NoFinalizer extends Finalizer(null, newTermNameCached("<no finalizer>"), NoPosition) { override def startBlock: BasicBlock = sys.error("NoFinalizer cannot have a start block."); override def setStartBlock(b: BasicBlock): Unit = sys.error("NoFinalizer cannot have a start block."); override def dup = this diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 2e34db09eb..803bd05031 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1293,7 +1293,7 @@ abstract class GenICode extends SubComponent { /** The Object => String overload. */ - private lazy val String_valueOf: Symbol = getMember(StringModule, "valueOf") filter (sym => + private lazy val String_valueOf: Symbol = getMember(StringModule, nme.valueOf) filter (sym => sym.info.paramTypes match { case List(pt) => pt.typeSymbol == ObjectClass case _ => false @@ -1305,7 +1305,7 @@ abstract class GenICode extends SubComponent { // case we want to get more precise. // // private def valueOfForType(tp: Type): Symbol = { - // val xs = getMember(StringModule, "valueOf") filter (sym => + // val xs = getMember(StringModule, nme.valueOf) filter (sym => // // We always exclude the Array[Char] overload because java throws an NPE if // // you pass it a null. It will instead find the Object one, which doesn't. // sym.info.paramTypes match { @@ -1352,7 +1352,7 @@ abstract class GenICode extends SubComponent { def genScalaHash(tree: Tree, ctx: Context): Context = { val hashMethod = { ctx.bb.emit(LOAD_MODULE(ScalaRunTimeModule)) - getMember(ScalaRunTimeModule, "hash") + getMember(ScalaRunTimeModule, nme.hash_) } val ctx1 = genLoad(tree, ctx, ObjectReference) @@ -1959,7 +1959,7 @@ abstract class GenICode extends SubComponent { */ private def newExceptionHandler(cls: Symbol, resultKind: TypeKind, pos: Position): ExceptionHandler = { handlerCount += 1 - val exh = new ExceptionHandler(method, "" + handlerCount, cls, pos) + val exh = new ExceptionHandler(method, newTermNameCached("" + handlerCount), cls, pos) exh.resultKind = resultKind method.addHandler(exh) handlers = exh :: handlers diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 4ef6766262..2668e7f29f 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -169,7 +169,6 @@ trait Members { var exh: List[ExceptionHandler] = Nil var sourceFile: SourceFile = NoSourceFile var returnType: TypeKind = _ - var recursive: Boolean = false /** local variables and method parameters */ diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala index 301dbd18d6..e7cf716add 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenAndroid.scala @@ -23,15 +23,10 @@ trait GenAndroid { * `Parcelable` interface must also have a static field called `CREATOR`, * which is an object implementing the `Parcelable.Creator` interface. */ - private val fieldName = "CREATOR" + private val fieldName = newTermName("CREATOR") - private lazy val AndroidParcelableInterface = - try definitions.getClass("android.os.Parcelable") - catch { case _: FatalError => NoSymbol } - - private lazy val AndroidCreatorClass = - if (AndroidParcelableInterface == NoSymbol) NoSymbol - else definitions.getClass("android.os.Parcelable$Creator") + private lazy val AndroidParcelableInterface = definitions.getClassIfDefined("android.os.Parcelable") + private lazy val AndroidCreatorClass = definitions.getClassIfDefined("android.os.Parcelable$Creator") def isAndroidParcelableClass(sym: Symbol) = (AndroidParcelableInterface != NoSymbol) && diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index e05dd28e00..03d1bc3ad2 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -183,10 +183,10 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val MethodHandleType = new JObjectType("java.dyn.MethodHandle") // Scala attributes - val BeanInfoAttr = definitions.getClass("scala.beans.BeanInfo") - val BeanInfoSkipAttr = definitions.getClass("scala.beans.BeanInfoSkip") - val BeanDisplayNameAttr = definitions.getClass("scala.beans.BeanDisplayName") - val BeanDescriptionAttr = definitions.getClass("scala.beans.BeanDescription") + val BeanInfoAttr = definitions.getRequiredClass("scala.beans.BeanInfo") + val BeanInfoSkipAttr = definitions.getRequiredClass("scala.beans.BeanInfoSkip") + val BeanDisplayNameAttr = definitions.getRequiredClass("scala.beans.BeanDisplayName") + val BeanDescriptionAttr = definitions.getRequiredClass("scala.beans.BeanDescription") final val ExcludedForwarderFlags = { import Flags._ @@ -296,7 +296,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with */ def scalaSignatureAddingMarker(jclass: JClass, sym: Symbol): Option[AnnotationInfo] = currentRun.symData get sym match { - case Some(pickle) if !nme.isModuleName(jclass.getName()) => + case Some(pickle) if !nme.isModuleName(newTermName(jclass.getName)) => val scalaAttr = fjbgContext.JOtherAttribute(jclass, jclass, tpnme.ScalaSignatureATTR.toString, versionPickle.bytes, versionPickle.writeIndex) @@ -759,7 +759,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with null else { val outerName = javaName(innerSym.rawowner) - if (isTopLevelModule(innerSym.rawowner)) "" + nme.stripModuleSuffix(outerName) + if (isTopLevelModule(innerSym.rawowner)) "" + nme.stripModuleSuffix(newTermName(outerName)) else outerName } } diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala index acaf1f6cc2..93d3d19ac8 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVMUtil.scala @@ -33,11 +33,11 @@ trait GenJVMUtil { ) // Don't put this in per run caches. - private val javaNameCache = new mutable.WeakHashMap[Symbol, String]() ++= List( - NothingClass -> RuntimeNothingClass.fullName('/'), - RuntimeNothingClass -> RuntimeNothingClass.fullName('/'), - NullClass -> RuntimeNullClass.fullName('/'), - RuntimeNullClass -> RuntimeNullClass.fullName('/') + private val javaNameCache = new mutable.WeakHashMap[Symbol, Name]() ++= List( + NothingClass -> binarynme.RuntimeNothing, + RuntimeNothingClass -> binarynme.RuntimeNothing, + NullClass -> binarynme.RuntimeNull, + RuntimeNullClass -> binarynme.RuntimeNull ) /** This trait may be used by tools who need access to @@ -70,7 +70,6 @@ trait GenJVMUtil { def mkArray(xs: Traversable[JType]): Array[JType] = { val a = new Array[JType](xs.size); xs.copyToArray(a); a } def mkArray(xs: Traversable[String]): Array[String] = { val a = new Array[String](xs.size); xs.copyToArray(a); a } - /** Return the a name of this symbol that can be used on the Java * platform. It removes spaces from names. * @@ -86,11 +85,13 @@ trait GenJVMUtil { */ def javaName(sym: Symbol): String = javaNameCache.getOrElseUpdate(sym, { - if (sym.isClass || (sym.isModule && !sym.isMethod)) - sym.javaBinaryName - else - sym.javaSimpleName - }) + sym.name.newName( + if (sym.isClass || (sym.isModule && !sym.isMethod)) + sym.javaBinaryName + else + sym.javaSimpleName + ) + }).toString def javaType(t: TypeKind): JType = (t: @unchecked) match { case UNIT => JType.VOID diff --git a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala index bf59d80cdd..d2e54ff3f1 100644 --- a/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala +++ b/src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala @@ -124,8 +124,8 @@ abstract class GenMSIL extends SubComponent { // Scala attributes // symtab.Definitions -> object (singleton..) val SerializableAttr = definitions.SerializableAttr.tpe - val CloneableAttr = definitions.getClass("scala.cloneable").tpe - val TransientAtt = definitions.getClass("scala.transient").tpe + val CloneableAttr = definitions.CloneableAttr.tpe + val TransientAtt = definitions.TransientAttr.tpe // remoting: the architectures are too different, no mapping (no portable code // possible) diff --git a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala index e01c42ad87..e3d21011d1 100644 --- a/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala +++ b/src/compiler/scala/tools/nsc/backend/opt/Inliners.scala @@ -85,9 +85,9 @@ abstract class Inliners extends SubComponent { /* fresh name counter */ val fresh = perRunCaches.newMap[String, Int]() withDefaultValue 0 - def freshName(s: String) = { + def freshName(s: String): TermName = { fresh(s) += 1 - s + fresh(s) + newTermName(s + fresh(s)) } private def hasInline(sym: Symbol) = sym hasAnnotation ScalaInlineClass diff --git a/src/compiler/scala/tools/nsc/dependencies/Changes.scala b/src/compiler/scala/tools/nsc/dependencies/Changes.scala index 4c7263ef69..089ef9cf35 100644 --- a/src/compiler/scala/tools/nsc/dependencies/Changes.scala +++ b/src/compiler/scala/tools/nsc/dependencies/Changes.scala @@ -18,8 +18,8 @@ abstract class Changes { abstract class Change - private lazy val annotationsChecked = - List(definitions.getClass("scala.specialized")) // Any others that should be checked? + private lazy val annotationsChecked = + List(definitions.SpecializedClass) // Any others that should be checked? private val flagsToCheck = IMPLICIT | FINAL | PRIVATE | PROTECTED | SEALED | OVERRIDE | CASE | ABSTRACT | DEFERRED | METHOD | diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index f900859f46..0fea0a2d92 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -818,7 +818,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") def add(sym: Symbol, pre: Type, implicitlyAdded: Boolean)(toMember: (Symbol, Type) => M) { if ((sym.isGetter || sym.isSetter) && sym.accessed != NoSymbol) { add(sym.accessed, pre, implicitlyAdded)(toMember) - } else if (!sym.name.decode.containsName(Dollar) && !sym.isSynthetic && sym.hasRawInfo) { + } else if (!sym.name.decodedName.containsName(Dollar) && !sym.isSynthetic && sym.hasRawInfo) { val symtpe = pre.memberType(sym) onTypeError ErrorType matching(sym, symtpe, this(sym.name)) match { case Some(m) => diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala index 2b6e793c5c..b7a9c7329c 100644 --- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala +++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala @@ -101,7 +101,7 @@ trait Picklers { self: Global => if (sym1.isOverloaded) { val index = sym1.alternatives.indexOf(sym) assert(index >= 0, sym1+" not found in alternatives "+sym1.alternatives) - buf += index.toString + buf += newTermName(index.toString) } } } diff --git a/src/compiler/scala/tools/nsc/interpreter/Dossiers.scala b/src/compiler/scala/tools/nsc/interpreter/Dossiers.scala index 2c556656ca..d889cadf47 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Dossiers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Dossiers.scala @@ -12,6 +12,7 @@ trait Dossiers { import intp._ import intp.global._ + import definitions._ trait Dossier { def symbol: Symbol @@ -34,7 +35,7 @@ trait Dossiers { class TermDossier(val symbol: TermSymbol, val staticType: Type, val value: AnyRef) extends Dossier { def runtimeClass: JClass = value.getClass - def runtimeSymbol: Symbol = safeClass(runtimeClass.getName) getOrElse NoSymbol + def runtimeSymbol: Symbol = getClassIfDefined(runtimeClass.getName) def runtimeType: Type = runtimeSymbol.tpe def runtimeTypeString = TypeStrings.fromClazz(runtimeClass) diff --git a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala index 115cef7f00..9f5fde70d8 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ExprTyper.scala @@ -15,6 +15,7 @@ trait ExprTyper { import repl._ import replTokens.{ Tokenizer } import global.{ reporter => _, Import => _, _ } + import definitions._ import syntaxAnalyzer.{ UnitParser, UnitScanner, token2name } import naming.freshInternalVarName @@ -70,30 +71,29 @@ trait ExprTyper { // 2) A path loadable via getModule. // 3) Try interpreting it as an expression. private var typeOfExpressionDepth = 0 - def typeOfExpression(expr: String, silent: Boolean = true): Option[Type] = { + def typeOfExpression(expr: String, silent: Boolean = true): Type = { repltrace("typeOfExpression(" + expr + ")") if (typeOfExpressionDepth > 2) { repldbg("Terminating typeOfExpression recursion for expression: " + expr) - return None + return NoType } - def asQualifiedImport = { + def asQualifiedImport: Type = { val name = expr.takeWhile(_ != '.') - importedTermNamed(name) flatMap { sym => - typeOfExpression(sym.fullName + expr.drop(name.length), true) - } + typeOfExpression(importedTermNamed(name).fullName + expr.drop(name.length), true) } - def asModule = safeModule(expr) map (_.tpe) - def asExpr = { + def asModule: Type = getModuleIfDefined(expr).tpe + def asExpr: Type = { val lhs = freshInternalVarName() val line = "lazy val " + lhs + " =\n" + expr interpret(line, true) match { case IR.Success => typeOfExpression(lhs, true) - case _ => None + case _ => NoType } } - def evaluate() = { + + def evaluate(): Type = { typeOfExpressionDepth += 1 try typeOfTerm(expr) orElse asModule orElse asExpr orElse asQualifiedImport finally typeOfExpressionDepth -= 1 @@ -107,26 +107,27 @@ trait ExprTyper { if (!silent) evaluate() - None + NoType } } // Since people will be giving us ":t def foo = 5" even though that is not an // expression, we have a means of typing declarations too. - private def typeOfDeclaration(code: String): Option[Type] = { + private def typeOfDeclaration(code: String): Type = { repltrace("typeOfDeclaration(" + code + ")") val obname = freshInternalVarName() interpret("object " + obname + " {\n" + code + "\n}\n", true) match { case IR.Success => val sym = symbolOfTerm(obname) - if (sym == NoSymbol) None else { + if (sym == NoSymbol) NoType else { // TODO: bitmap$n is not marked synthetic. val decls = sym.tpe.decls.toList filterNot (x => x.isConstructor || x.isPrivate || (x.name.toString contains "$")) repltrace("decls: " + decls) - decls.lastOption map (decl => typeCleanser(sym, decl.name)) + if (decls.isEmpty) NoType + else typeCleanser(sym, decls.last.name) } case _ => - None + NoType } } // def compileAndTypeExpr(expr: String): Option[Typer] = { diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala index 2159ecbb8a..0dc51d5eb0 100644 --- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala +++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala @@ -53,6 +53,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) def isAsync = !settings.Yreplsync.value lazy val power = new Power(intp, new StdReplVals(this)) + lazy val NoType = intp.global.NoType // TODO // object opt extends AestheticSettings @@ -436,9 +437,10 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) // Still todo: modules. private def typeCommand(line: String): Result = { if (line.trim == "") ":type <expression>" - else intp.typeOfExpression(line, false) match { - case Some(tp) => intp.afterTyper(tp.toString) - case _ => "" // the error message was already printed + else { + val tp = intp.typeOfExpression(line, false) + if (tp == NoType) "" // the error message was already printed + else intp.afterTyper(tp.toString) } } private def warningsCommand(): Result = { @@ -485,13 +487,14 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter) } case wrapper :: Nil => intp.typeOfExpression(wrapper) match { - case Some(PolyType(List(targ), MethodType(List(arg), restpe))) => + case PolyType(List(targ), MethodType(List(arg), restpe)) => intp setExecutionWrapper intp.pathToTerm(wrapper) "Set wrapper to '" + wrapper + "'" - case Some(x) => - failMsg + "\nFound: " + x - case _ => - failMsg + "\nFound: <unknown>" + case tp => + failMsg + ( + if (tp == g.NoType) "\nFound: <unknown>" + else "\nFound: <unknown>" + ) } case _ => failMsg } diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 8e4ff8aa37..0f0ab69e6d 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -188,7 +188,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends import global._ import definitions.{ ScalaPackage, JavaLangPackage, PredefModule, RootClass, - getClassIfDefined, getModuleIfDefined + getClassIfDefined, getModuleIfDefined, getRequiredModule, getRequiredClass } private implicit def privateTreeOps(t: Tree): List[Tree] = { @@ -196,6 +196,12 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def foreach[U](f: Tree => U): Unit = t foreach { x => f(x) ; () } }).toList } + + implicit def installReplTypeOps(tp: Type): ReplTypeOps = new ReplTypeOps(tp) + class ReplTypeOps(tp: Type) { + def orElse(other: => Type): Type = if (tp ne NoType) tp else other + def andAlso(fn: Type => Type): Type = if (tp eq NoType) tp else fn(tp) + } // TODO: If we try to make naming a lazy val, we run into big time // scalac unhappiness with what look like cycles. It has not been easy to @@ -204,12 +210,13 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends val global: imain.global.type = imain.global } with Naming { // make sure we don't overwrite their unwisely named res3 etc. - override def freshUserVarName(): String = { - val name = super.freshUserVarName() - if (definedNameMap contains name) freshUserVarName() + def freshUserTermName(): TermName = { + val name = newTermName(freshUserVarName()) + if (definedNameMap contains name) freshUserTermName() else name } - def isInternalVarName(name: Name): Boolean = isInternalVarName("" + name) + def isUserTermName(name: Name) = isUserVarName("" + name) + def isInternalTermName(name: Name) = isInternalVarName("" + name) } import naming._ @@ -359,7 +366,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends private def mostRecentlyHandledTree: Option[Tree] = { prevRequests.reverse foreach { req => req.handlers.reverse foreach { - case x: MemberDefHandler if x.definesValue && !isInternalVarName(x.name) => return Some(x.member) + case x: MemberDefHandler if x.definesValue && !isInternalTermName(x.name) => return Some(x.member) case _ => () } } @@ -501,7 +508,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends trees.last match { case _:Assign => // we don't want to include assignments case _:TermTree | _:Ident | _:Select => // ... but do want other unnamed terms. - val varName = if (synthetic) freshInternalVarName() else freshUserVarName() + val varName = if (synthetic) freshInternalVarName() else ("" + freshUserTermName()) val rewrittenLine = ( // In theory this would come out the same without the 1-specific test, but // it's a cushion against any more sneaky parse-tree position vs. code mismatches: @@ -643,7 +650,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def directBind(name: String, boundType: String, value: Any): IR.Result = { val result = bind(name, boundType, value) if (result == IR.Success) - directlyBoundNames += name + directlyBoundNames += newTermName(name) result } def directBind(p: NamedParam): IR.Result = directBind(p.name, p.tpe, p.value) @@ -651,7 +658,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def rebind(p: NamedParam): IR.Result = { val name = p.name - val oldType = typeOfTerm(name) getOrElse { return IR.Error } + val oldType = typeOfTerm(name) orElse { return IR.Error } val newType = p.tpe val tempName = freshInternalVarName() @@ -666,7 +673,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def quietBind(p: NamedParam): IR.Result = beQuietDuring(bind(p)) def bind(p: NamedParam): IR.Result = bind(p.name, p.tpe, p.value) def bind[T: Manifest](name: String, value: T): IR.Result = bind((name, value)) - def bindValue(x: Any): IR.Result = bindValue(freshUserVarName(), x) + def bindValue(x: Any): IR.Result = bindValue("" + freshUserTermName(), x) def bindValue(name: String, x: Any): IR.Result = bind(name, TypeStrings.fromValue(x), x) /** Reset this interpreter, forgetting all user-specified requests. */ @@ -789,7 +796,7 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends * following accessPath into the outer one. */ def resolvePathToSymbol(accessPath: String): Symbol = { - val readRoot = definitions.getModule(readPath) // the outermost wrapper + val readRoot = getRequiredModule(readPath) // the outermost wrapper (accessPath split '.').foldLeft(readRoot) { (sym, name) => if (name == "") sym else lineAfterTyper(sym.info member newTermName(name)) @@ -1039,16 +1046,6 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def requestHistoryForName(name: Name): List[Request] = prevRequests.toList.reverse filter (_.definedNames contains name) - def safeClass(name: String): Option[Symbol] = { - try Some(definitions.getClass(newTypeName(name))) - catch { case _: MissingRequirementError => None } - } - - def safeModule(name: String): Option[Symbol] = { - try Some(definitions.getModule(newTermName(name))) - catch { case _: MissingRequirementError => None } - } - def definitionForName(name: Name): Option[MemberHandler] = requestForName(name) flatMap { req => req.handlers find (_.definedNames contains name) @@ -1060,34 +1057,32 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends def classOfTerm(id: String): Option[JClass] = valueOfTerm(id) map (_.getClass) - def typeOfTerm(id: String): Option[Type] = newTermName(id) match { - case nme.ROOTPKG => Some(definitions.RootClass.tpe) - case name => requestForName(name) flatMap (_.compilerTypeOf get name) + def typeOfTerm(id: String): Type = newTermName(id) match { + case nme.ROOTPKG => definitions.RootClass.tpe + case name => requestForName(name) flatMap (_.compilerTypeOf get name) getOrElse NoType } def symbolOfTerm(id: String): Symbol = requestForIdent(id) flatMap (_.definedSymbols get newTermName(id)) getOrElse NoSymbol def runtimeClassAndTypeOfTerm(id: String): Option[(JClass, Type)] = { - for { - clazz <- classOfTerm(id) - tpe <- runtimeTypeOfTerm(id) - nonAnon <- clazz.supers find (!_.isScalaAnonymous) - } yield { - (nonAnon, tpe) + classOfTerm(id) flatMap { clazz => + clazz.supers find (!_.isScalaAnonymous) map { nonAnon => + (nonAnon, runtimeTypeOfTerm(id)) + } } } - def runtimeTypeOfTerm(id: String): Option[Type] = { - for { - tpe <- typeOfTerm(id) - clazz <- classOfTerm(id) - staticSym = tpe.typeSymbol - runtimeSym <- safeClass(clazz.getName) - if runtimeSym != staticSym - if runtimeSym isSubClass staticSym + def runtimeTypeOfTerm(id: String): Type = { + typeOfTerm(id) andAlso { tpe => + val clazz = classOfTerm(id) getOrElse { return NoType } + val staticSym = tpe.typeSymbol + val runtimeSym = getClassIfDefined(clazz.getName) + + if ((runtimeSym != NoSymbol) && (runtimeSym != staticSym) && (runtimeSym isSubClass staticSym)) + runtimeSym.info + else NoType } - yield runtimeSym.info } object replTokens extends { @@ -1099,16 +1094,16 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends } with ExprTyper { } def parse(line: String): Option[List[Tree]] = exprTyper.parse(line) - def typeOfExpression(expr: String, silent: Boolean = true): Option[Type] = { + def typeOfExpression(expr: String, silent: Boolean = true): Type = exprTyper.typeOfExpression(expr, silent) - } + def prettyPrint(code: String) = replTokens.prettyPrint(exprTyper tokens code) protected def onlyTerms(xs: List[Name]) = xs collect { case x: TermName => x } protected def onlyTypes(xs: List[Name]) = xs collect { case x: TypeName => x } - def definedTerms = onlyTerms(allDefinedNames) filterNot isInternalVarName + def definedTerms = onlyTerms(allDefinedNames) filterNot isInternalTermName def definedTypes = onlyTypes(allDefinedNames) def definedSymbols = prevRequests.toSet flatMap ((x: Request) => x.definedSymbols.values) diff --git a/src/compiler/scala/tools/nsc/interpreter/Imports.scala b/src/compiler/scala/tools/nsc/interpreter/Imports.scala index 10e3796404..d34ca8bbca 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Imports.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Imports.scala @@ -34,8 +34,9 @@ trait Imports { def languageWildcards: List[Type] = languageWildcardSyms map (_.tpe) def languageWildcardHandlers = languageWildcardSyms map makeWildcardImportHandler - def importedTerms = onlyTerms(importHandlers flatMap (_.importedNames)) - def importedTypes = onlyTypes(importHandlers flatMap (_.importedNames)) + def allImportedNames = importHandlers flatMap (_.importedNames) + def importedTerms = onlyTerms(allImportedNames) + def importedTypes = onlyTypes(allImportedNames) /** Types which have been wildcard imported, such as: * val x = "abc" ; import x._ // type java.lang.String @@ -49,10 +50,7 @@ trait Imports { * into the compiler scopes. */ def sessionWildcards: List[Type] = { - importHandlers flatMap { - case x if x.importsWildcard => x.targetType - case _ => None - } distinct + importHandlers filter (_.importsWildcard) map (_.targetType) distinct } def wildcardTypes = languageWildcards ++ sessionWildcards @@ -63,14 +61,15 @@ trait Imports { def importedTypeSymbols = importedSymbols collect { case x: TypeSymbol => x } def implicitSymbols = importedSymbols filter (_.isImplicit) - def importedTermNamed(name: String) = importedTermSymbols find (_.name.toString == name) + def importedTermNamed(name: String): Symbol = + importedTermSymbols find (_.name.toString == name) getOrElse NoSymbol /** Tuples of (source, imported symbols) in the order they were imported. */ def importedSymbolsBySource: List[(Symbol, List[Symbol])] = { val lang = languageWildcardSyms map (sym => (sym, membersAtPickler(sym))) - val session = importHandlers filter (_.targetType.isDefined) map { mh => - (mh.targetType.get.typeSymbol, mh.importedSymbols) + val session = importHandlers filter (_.targetType != NoType) map { mh => + (mh.targetType.typeSymbol, mh.importedSymbols) } lang ++ session diff --git a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala index 9c5299b633..d96e8b07fc 100644 --- a/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/JLineCompletion.scala @@ -16,7 +16,7 @@ import collection.mutable.ListBuffer class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput { val global: intp.global.type = intp.global import global._ - import definitions.{ PredefModule, RootClass, AnyClass, AnyRefClass, ScalaPackage, JavaLangPackage } + import definitions.{ PredefModule, RootClass, AnyClass, AnyRefClass, ScalaPackage, JavaLangPackage, getModuleIfDefined } type ExecResult = Any import intp.{ debugging, afterTyper } @@ -24,14 +24,13 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput private var verbosity: Int = 0 def resetVerbosity() = verbosity = 0 - def getType(name: String, isModule: Boolean) = { - val f = if (isModule) definitions.getModule(_: Name) else definitions.getClass(_: Name) - try Some(f(name).tpe) - catch { case _: MissingRequirementError => None } - } - - def typeOf(name: String) = getType(name, false) - def moduleOf(name: String) = getType(name, true) + def getSymbol(name: String, isModule: Boolean) = ( + if (isModule) getModuleIfDefined(name) + else getModuleIfDefined(name) + ) + def getType(name: String, isModule: Boolean) = getSymbol(name, isModule).tpe + def typeOf(name: String) = getType(name, false) + def moduleOf(name: String) = getType(name, true) trait CompilerCompletion { def tp: Type @@ -46,9 +45,9 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput private def anyMembers = AnyClass.tpe.nonPrivateMembers def anyRefMethodsToShow = Set("isInstanceOf", "asInstanceOf", "toString") - def tos(sym: Symbol) = sym.name.decode.toString - def memberNamed(s: String) = members find (x => tos(x) == s) - def hasMethod(s: String) = methods exists (x => tos(x) == s) + def tos(sym: Symbol): String = sym.decodedName + def memberNamed(s: String) = afterTyper(effectiveTp member newTermName(s)) + def hasMethod(s: String) = memberNamed(s).isMethod // XXX we'd like to say "filterNot (_.isDeprecated)" but this causes the // compiler to crash for reasons not yet known. @@ -62,6 +61,13 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput def packageNames = packages map tos def aliasNames = aliases map tos } + + object NoTypeCompletion extends TypeMemberCompletion(NoType) { + override def memberNamed(s: String) = NoSymbol + override def members = Nil + override def follow(s: String) = None + override def alternativesFor(id: String) = Nil + } object TypeMemberCompletion { def apply(tp: Type, runtimeType: Type, param: NamedParam): TypeMemberCompletion = { @@ -90,7 +96,8 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput } } def apply(tp: Type): TypeMemberCompletion = { - if (tp.typeSymbol.isPackageClass) new PackageCompletion(tp) + if (tp eq NoType) NoTypeCompletion + else if (tp.typeSymbol.isPackageClass) new PackageCompletion(tp) else new TypeMemberCompletion(tp) } def imported(tp: Type) = new ImportCompletion(tp) @@ -118,7 +125,7 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput debugging(tp + " completions ==> ")(filtered(memberNames)) override def follow(s: String): Option[CompletionAware] = - debugging(tp + " -> '" + s + "' ==> ")(memberNamed(s) map (x => TypeMemberCompletion(x.tpe))) + debugging(tp + " -> '" + s + "' ==> ")(Some(TypeMemberCompletion(memberNamed(s).tpe)) filterNot (_ eq NoTypeCompletion)) override def alternativesFor(id: String): List[String] = debugging(id + " alternatives ==> ") { @@ -155,28 +162,29 @@ class JLineCompletion(val intp: IMain) extends Completion with CompletionOutput object ids extends CompletionAware { override def completions(verbosity: Int) = intp.unqualifiedIds ++ List("classOf") //, "_root_") // now we use the compiler for everything. - override def follow(id: String) = { - if (completions(0) contains id) { - intp typeOfExpression id map { tpe => - def default = TypeMemberCompletion(tpe) - - // only rebinding vals in power mode for now. - if (!isReplPower) default - else intp runtimeClassAndTypeOfTerm id match { - case Some((clazz, runtimeType)) => - val sym = intp.symbolOfTerm(id) - if (sym.isStable) { - val param = new NamedParam.Untyped(id, intp valueOfTerm id getOrElse null) - TypeMemberCompletion(tpe, runtimeType, param) - } - else default - case _ => - default + override def follow(id: String): Option[CompletionAware] = { + if (!completions(0).contains(id)) + return None + + val tpe = intp typeOfExpression id + if (tpe == NoType) + return None + + def default = Some(TypeMemberCompletion(tpe)) + + // only rebinding vals in power mode for now. + if (!isReplPower) default + else intp runtimeClassAndTypeOfTerm id match { + case Some((clazz, runtimeType)) => + val sym = intp.symbolOfTerm(id) + if (sym.isStable) { + val param = new NamedParam.Untyped(id, intp valueOfTerm id getOrElse null) + Some(TypeMemberCompletion(tpe, runtimeType, param)) } - } + else default + case _ => + default } - else - None } override def toString = "<repl ids> (%s)".format(completions(0).size) } diff --git a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala index b64f14e929..c742ab89c0 100644 --- a/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala +++ b/src/compiler/scala/tools/nsc/interpreter/MemberHandlers.scala @@ -169,7 +169,7 @@ trait MemberHandlers { class ImportHandler(imp: Import) extends MemberHandler(imp) { val Import(expr, selectors) = imp - def targetType = intp.typeOfExpression("" + expr) + def targetType: Type = intp.typeOfExpression("" + expr) override def isLegalTopLevel = true def createImportForName(name: Name): String = { @@ -199,10 +199,10 @@ trait MemberHandlers { def importedSymbols = individualSymbols ++ wildcardSymbols lazy val individualSymbols: List[Symbol] = - atPickler(targetType.toList flatMap (tp => individualNames map (tp nonPrivateMember _))) + atPickler(individualNames map (targetType nonPrivateMember _)) lazy val wildcardSymbols: List[Symbol] = - if (importsWildcard) atPickler(targetType.toList flatMap (_.nonPrivateMembers)) + if (importsWildcard) atPickler(targetType.nonPrivateMembers) else Nil /** Complete list of names imported by a wildcard */ diff --git a/src/compiler/scala/tools/nsc/interpreter/Naming.scala b/src/compiler/scala/tools/nsc/interpreter/Naming.scala index 7377953263..8e215cf63b 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Naming.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Naming.scala @@ -84,7 +84,7 @@ trait Naming { var x = 0 () => { x += 1 ; x } } - def freshUserVarName() = userVar() + def freshUserVarName() = userVar() def freshInternalVarName() = internalVar() def resetAllCreators() { diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index 82a466a7e5..b4a9b9b0e3 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -353,7 +353,7 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl def source(code: String) = new BatchSourceFile("<console>", code) def unit(code: String) = new CompilationUnit(source(code)) def trees(code: String) = parse(code) getOrElse Nil - def typeOf(id: String): Type = intp.typeOfExpression(id) getOrElse NoType + def typeOf(id: String) = intp.typeOfExpression(id) override def toString = """ |** Power mode status ** diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 742e9e03ca..0d7afdc4ec 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -547,7 +547,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { if (parentToken == AT && in.token == DEFAULT) { val annot = atPos(pos) { - New(Select(scalaDot(newTermName("runtime")), tpnme.AnnotationDefaultATTR), List(List())) + New(Select(scalaDot(nme.runtime), tpnme.AnnotationDefaultATTR), List(List())) } mods1 = mods1 withAnnotations List(annot) skipTo(SEMI) @@ -794,9 +794,9 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { accept(INTERFACE) val pos = in.currentPos val name = identForType() - val parents = List(scalaDot(newTypeName("Annotation")), - Select(javaLangDot(newTermName("annotation")), newTypeName("Annotation")), - scalaDot(newTypeName("ClassfileAnnotation"))) + val parents = List(scalaDot(tpnme.Annotation), + Select(javaLangDot(nme.annotation), tpnme.Annotation), + scalaDot(tpnme.ClassfileAnnotation)) val (statics, body) = typeBody(AT, name) def getValueMethodType(tree: Tree) = tree match { case DefDef(_, nme.value, _, _, tpt, _) => Some(tpt.duplicate) @@ -838,18 +838,18 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { } val predefs = List( DefDef( - Modifiers(Flags.JAVA | Flags.STATIC), newTermName("values"), List(), + Modifiers(Flags.JAVA | Flags.STATIC), nme.values, List(), List(List()), arrayOf(enumType), blankExpr), DefDef( - Modifiers(Flags.JAVA | Flags.STATIC), newTermName("valueOf"), List(), + Modifiers(Flags.JAVA | Flags.STATIC), nme.valueOf, List(), List(List(makeParam("x", TypeTree(StringClass.tpe)))), enumType, blankExpr)) accept(RBRACE) val superclazz = - AppliedTypeTree(javaLangDot(newTypeName("Enum")), List(enumType)) + AppliedTypeTree(javaLangDot(tpnme.Enum), List(enumType)) addCompanionObject(consts ::: statics ::: predefs, atPos(pos) { ClassDef(mods, name, List(), makeTemplate(superclazz :: interfaces, body)) diff --git a/src/compiler/scala/tools/nsc/matching/Patterns.scala b/src/compiler/scala/tools/nsc/matching/Patterns.scala index 420fba911b..e5748b7c23 100644 --- a/src/compiler/scala/tools/nsc/matching/Patterns.scala +++ b/src/compiler/scala/tools/nsc/matching/Patterns.scala @@ -36,6 +36,9 @@ trait Patterns extends ast.TreeDSL { // case _ => NoSymbol // } + private lazy val dummyMethod = + new TermSymbol(NoSymbol, NoPosition, newTermName("matching$dummy")) + // Fresh patterns def emptyPatterns(i: Int): List[Pattern] = List.fill(i)(NoPattern) def emptyTrees(i: Int): List[Tree] = List.fill(i)(EmptyTree) @@ -191,9 +194,9 @@ trait Patterns extends ast.TreeDSL { // As yet I can't testify this is doing any good relative to using // tpt.tpe, but it doesn't seem to hurt either. private lazy val packedType = global.typer.computeType(tpt, tpt.tpe) - private lazy val consRef = typeRef(NoPrefix, ConsClass, List(packedType)) - private lazy val listRef = typeRef(NoPrefix, ListClass, List(packedType)) - private lazy val seqRef = typeRef(NoPrefix, SeqClass, List(packedType)) + private lazy val consRef = appliedType(ConsClass.typeConstructor, List(packedType)) + private lazy val listRef = appliedType(ListClass.typeConstructor, List(packedType)) + private lazy val seqRef = appliedType(SeqClass.typeConstructor, List(packedType)) private def thisSeqRef = { val tc = (tree.tpe baseType SeqClass).typeConstructor @@ -205,7 +208,6 @@ trait Patterns extends ast.TreeDSL { private def listFolder(hd: Tree, tl: Tree): Tree = unbind(hd) match { case t @ Star(_) => moveBindings(hd, WILD(t.tpe)) case _ => - val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "matching$dummy") val consType = MethodType(dummyMethod newSyntheticValueParams List(packedType, listRef), consRef) Apply(TypeTree(consType), List(hd, tl)) setType consRef diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 94eb6d2afd..ac72b4d22c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -440,18 +440,18 @@ abstract class ClassfileParser { /** Return the class symbol of the given name. */ def classNameToSymbol(name: Name): Symbol = { def loadClassSymbol(name: Name) = { - val s = name.toString - val file = global.classPath findSourceFile s getOrElse { - MissingRequirementError.notFound("class " + s) + val file = global.classPath findSourceFile ("" +name) getOrElse { + MissingRequirementError.notFound("class " + name) } - val completer = new global.loaders.ClassfileLoader(file) + val completer = new global.loaders.ClassfileLoader(file) var owner: Symbol = definitions.RootClass - var sym: Symbol = NoSymbol - var ss: String = null - var start = 0 - var end = s indexOf '.' + var sym: Symbol = NoSymbol + var ss: Name = null + var start = 0 + var end = name indexOf '.' + while (end > 0) { - ss = s.substring(start, end) + ss = name.subName(start, end) sym = owner.info.decls lookup ss if (sym == NoSymbol) { sym = owner.newPackage(NoPosition, ss) setInfo completer @@ -460,17 +460,16 @@ abstract class ClassfileParser { } owner = sym.moduleClass start = end + 1 - end = s.indexOf('.', start) + end = name.indexOf('.', start) } - ss = s substring start - sym = owner.info.decls lookup ss - if (sym == NoSymbol) { - sym = owner.newClass(NoPosition, newTypeName(ss)) setInfo completer - owner.info.decls enter sym - if (settings.debug.value && settings.verbose.value) + ss = name.subName(0, start) + owner.info.decls lookup ss orElse { + sym = owner.newClass(NoPosition, ss.toTypeName) setInfo completer + if (opt.verboseDebug) println("loaded "+sym+" from file "+file) + + owner.info.decls enter sym } - sym } def lookupClass(name: Name) = try { diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index abc1dd387c..0b64a49a2c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -26,9 +26,6 @@ abstract class ICodeReader extends ClassfileParser { var instanceCode: IClass = null // the ICode class for the current symbol var staticCode: IClass = null // the ICode class static members var method: IMethod = NoIMethod // the current IMethod - - val nothingName = newTermName(SCALA_NOTHING) - val nullName = newTermName(SCALA_NULL) var isScalaModule = false /** Read back bytecode for the given class symbol. It returns @@ -182,9 +179,9 @@ abstract class ICodeReader extends ClassfileParser { } override def classNameToSymbol(name: Name) = { - val sym = if (name == nothingName) + val sym = if (name == fulltpnme.RuntimeNothing) definitions.NothingClass - else if (name == nullName) + else if (name == fulltpnme.RuntimeNull) definitions.NullClass else if (nme.isImplClassName(name)) { val iface = definitions.getClass(nme.interfaceName(name)) @@ -194,7 +191,7 @@ abstract class ICodeReader extends ClassfileParser { } else if (nme.isModuleName(name)) { val strippedName = nme.stripModuleSuffix(name) - val sym = forceMangledName(strippedName.decode, true) + val sym = forceMangledName(newTermName(strippedName.decode), true) if (sym == NoSymbol) definitions.getModule(strippedName) else sym @@ -991,7 +988,7 @@ abstract class ICodeReader extends ClassfileParser { /** Return a fresh Local variable for the given index. */ private def freshLocal(idx: Int, kind: TypeKind, isArg: Boolean) = { - val sym = method.symbol.newVariable(NoPosition, "loc" + idx).setInfo(kind.toType); + val sym = method.symbol.newVariable(NoPosition, newTermName("loc" + idx)).setInfo(kind.toType); val l = new Local(sym, kind, isArg) method.addLocal(l) l @@ -1008,7 +1005,7 @@ abstract class ICodeReader extends ClassfileParser { /** add a method param with the given index. */ def enterParam(idx: Int, kind: TypeKind) = { - val sym = method.symbol.newVariable(NoPosition, "par" + idx).setInfo(kind.toType) + val sym = method.symbol.newVariable(NoPosition, newTermName("par" + idx)).setInfo(kind.toType) val l = new Local(sym, kind, true) assert(!locals.isDefinedAt(idx)) locals += (idx -> List((l, kind))) diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala index 728593abe7..676c8f09da 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/MetaParser.scala @@ -49,7 +49,7 @@ abstract class MetaParser{ val sym = locals.lookup(newTypeName(str)) if (sym != NoSymbol) sym.tpe else { - val tp = definitions.getClass(str).tpe; + val tp = definitions.getRequiredClass(str).tpe; if (token != "[") tp else { val args = new ListBuffer[Type]; diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala index 95ef799720..e0cb0848be 100644 --- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala @@ -34,6 +34,8 @@ abstract class TypeParser { protected var busy: Boolean = false // lock to detect recursive reads + private implicit def stringToTermName(s: String): TermName = newTermName(s) + private object unpickler extends UnPickler { val global: TypeParser.this.global.type = TypeParser.this.global } @@ -153,8 +155,8 @@ abstract class TypeParser { val canBeTakenAddressOf = (typ.IsValueType || typ.IsEnum) && (typ.FullName != "System.Enum") if(canBeTakenAddressOf) { - clazzBoxed = clazz.owner.newClass(clazz.name.toTypeName append "Boxed") - clazzMgdPtr = clazz.owner.newClass(clazz.name.toTypeName append "MgdPtr") + clazzBoxed = clazz.owner.newClass(clazz.name.toTypeName append newTypeName("Boxed")) + clazzMgdPtr = clazz.owner.newClass(clazz.name.toTypeName append newTypeName("MgdPtr")) clrTypes.mdgptrcls4clssym(clazz) = clazzMgdPtr /* adding typMgdPtr to clrTypes.sym2type should happen early (before metadata for supertypes is parsed, before metadata for members are parsed) so that clazzMgdPtr can be found by getClRType. */ diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala index f04867b889..575e3a9141 100644 --- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala +++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala @@ -274,69 +274,25 @@ abstract class CleanUp extends Transform with ast.TreeDSL { /* ### HANDLING METHODS NORMALLY COMPILED TO OPERATORS ### */ - val testForNumber: Tree => Tree = { - // Can't shortcut on BoxedNumber because BoxesRunTime - // is unforgiving of other Numbers showing up. - qual1 => ( - (qual1 IS_OBJ BoxedIntClass.tpe) - OR (qual1 IS_OBJ BoxedLongClass.tpe) - OR (qual1 IS_OBJ BoxedDoubleClass.tpe) - OR (qual1 IS_OBJ BoxedFloatClass.tpe) - OR (qual1 IS_OBJ BoxedByteClass.tpe) - OR (qual1 IS_OBJ BoxedShortClass.tpe) - OR (qual1 IS_OBJ BoxedCharacterClass.tpe) - ) - } - val testForBoolean: Tree => Tree = { - qual1 => (qual1 IS_OBJ BoxedBooleanClass.tpe) - } - val testForNumberOrBoolean: Tree => Tree = { - qual1 => testForNumber(qual1) OR testForBoolean(qual1) - } - - def postfixTest(name: Name): Option[(String, Tree => Tree)] = { - var runtimeTest: Tree => Tree = testForNumber - val newName = name match { - case nme.UNARY_! => runtimeTest = testForBoolean ; "takeNot" - case nme.UNARY_+ => "positive" - case nme.UNARY_- => "negate" - case nme.UNARY_~ => "complement" - case nme.toByte => "toByte" - case nme.toShort => "toShort" - case nme.toChar => "toCharacter" - case nme.toInt => "toInteger" - case nme.toLong => "toLong" - case nme.toFloat => "toFloat" - case nme.toDouble => "toDouble" - case _ => return None - } - Some((newName, runtimeTest)) - } - def infixTest(name: Name): Option[(String, Tree => Tree)] = { - val (newName, runtimeTest) = name match { - case nme.OR => ("takeOr", testForNumberOrBoolean) - case nme.XOR => ("takeXor", testForNumberOrBoolean) - case nme.AND => ("takeAnd", testForNumberOrBoolean) - case nme.EQ => ("testEqual", testForNumberOrBoolean) - case nme.NE => ("testNotEqual", testForNumberOrBoolean) - case nme.ADD => ("add", testForNumber) - case nme.SUB => ("subtract", testForNumber) - case nme.MUL => ("multiply", testForNumber) - case nme.DIV => ("divide", testForNumber) - case nme.MOD => ("takeModulo", testForNumber) - case nme.LSL => ("shiftSignedLeft", testForNumber) - case nme.LSR => ("shiftLogicalRight", testForNumber) - case nme.ASR => ("shiftSignedRight", testForNumber) - case nme.LT => ("testLessThan", testForNumber) - case nme.LE => ("testLessOrEqualThan", testForNumber) - case nme.GE => ("testGreaterOrEqualThan", testForNumber) - case nme.GT => ("testGreaterThan", testForNumber) - case nme.ZOR => ("takeConditionalOr", testForBoolean) - case nme.ZAND => ("takeConditionalAnd", testForBoolean) - case _ => return None - } - Some((newName, runtimeTest)) - } + // Can't shortcut on BoxedNumber because BoxesRunTime + // is unforgiving of other Numbers showing up. + def testForNumber(qual1: Tree): Tree = ( + (qual1 IS_OBJ BoxedIntClass.tpe) + OR (qual1 IS_OBJ BoxedLongClass.tpe) + OR (qual1 IS_OBJ BoxedDoubleClass.tpe) + OR (qual1 IS_OBJ BoxedFloatClass.tpe) + OR (qual1 IS_OBJ BoxedByteClass.tpe) + OR (qual1 IS_OBJ BoxedShortClass.tpe) + OR (qual1 IS_OBJ BoxedCharacterClass.tpe) + ) + def testForBoolean(qual1: Tree): Tree = ( + (qual1 IS_OBJ BoxedBooleanClass.tpe) + ) + def testForName(name: Name): Tree => Tree = ( + if (nme.CommonOpNames(name)) t => testForNumber(t) OR testForBoolean(t) + else if (nme.BooleanOpNames(name)) testForBoolean + else testForNumber + ) /** The Tree => Tree function in the return is necessary to prevent the original qual * from being duplicated in the resulting code. It may be a side-effecting expression, @@ -345,12 +301,13 @@ abstract class CleanUp extends Transform with ast.TreeDSL { * (If the compiler can verify qual is safe to inline, it will not create the block.) */ def getPrimitiveReplacementForStructuralCall(name: Name): Option[(Symbol, Tree => Tree)] = { - val opt = ( - if (params.isEmpty) postfixTest(name) - else if (params.tail.isEmpty) infixTest(name) - else None + val methodName = ( + if (params.isEmpty) nme.primitivePostfixMethodName(name) + else if (params.tail.isEmpty) nme.primitiveInfixMethodName(name) + else nme.NO_NAME ) - opt map { case (name, fn) => (getMember(BoxesRunTimeClass, name), fn) } + if (methodName == nme.NO_NAME) None + else Some((getMember(BoxesRunTimeClass, methodName), testForName(name))) } /* ### BOXING PARAMS & UNBOXING RESULTS ### */ diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index e03f329577..4d4f4f4c27 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -291,11 +291,10 @@ abstract class Constructors extends Transform with ast.TreeDSL { * be an error to pass it to array_update(.., .., Object). */ def rewriteArrayUpdate(tree: Tree): Tree = { - val array_update = definitions.ScalaRunTimeModule.info.member("array_update") val adapter = new Transformer { override def transform(t: Tree): Tree = t match { - case Apply(fun @ Select(receiver, method), List(xs, idx, v)) if fun.symbol == array_update => - localTyper.typed(Apply(gen.mkAttributedSelect(xs, definitions.Array_update), List(idx, v))) + case Apply(fun @ Select(receiver, method), List(xs, idx, v)) if fun.symbol == arrayUpdateMethod => + localTyper.typed(Apply(gen.mkAttributedSelect(xs, arrayUpdateMethod), List(idx, v))) case _ => super.transform(t) } } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 1a421eb82f..b327579c8b 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -866,7 +866,7 @@ abstract class Erasure extends AddInterfaces unboundedGenericArrayLevel(arg.tpe) > 0) => val level = unboundedGenericArrayLevel(arg.tpe) def isArrayTest(arg: Tree) = - gen.mkRuntimeCall("isArray", List(arg, Literal(Constant(level)))) + gen.mkRuntimeCall(nme.isArray, List(arg, Literal(Constant(level)))) global.typer.typedPos(tree.pos) { if (level == 1) isArrayTest(qual) @@ -891,7 +891,16 @@ abstract class Erasure extends AddInterfaces if (unboundedGenericArrayLevel(qual.tpe.widen) == 1) // convert calls to apply/update/length on generic arrays to // calls of ScalaRunTime.array_xxx method calls - global.typer.typedPos(tree.pos) { gen.mkRuntimeCall("array_"+name, qual :: args) } + global.typer.typedPos(tree.pos)({ + val arrayMethodName = name match { + case nme.apply => nme.array_apply + case nme.length => nme.array_length + case nme.update => nme.array_update + case nme.clone_ => nme.array_clone + case _ => unit.error(tree.pos, "Unexpected array member, no translation exists.") ; nme.NO_NAME + } + gen.mkRuntimeCall(arrayMethodName, qual :: args) + }) else // store exact array erasure in map to be retrieved later when we might // need to do the cast in adaptMember diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index fcc03a82d0..cf7d6c94fe 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -68,6 +68,8 @@ abstract class ExplicitOuter extends InfoTransform result } + + private val innerClassConstructorParamName: TermName = newTermName("arg" + nme.OUTER) class RemoveBindingsTransformer(toRemove: Set[Symbol]) extends Transformer { override def transform(tree: Tree) = tree match { @@ -134,7 +136,7 @@ abstract class ExplicitOuter extends InfoTransform } if (sym.owner.isTrait) sym setNotFlag PROTECTED // 6 if (sym.isClassConstructor && isInner(sym.owner)) { // 1 - val p = sym.newValueParameter(sym.pos, "arg" + nme.OUTER) + val p = sym.newValueParameter(sym.pos, innerClassConstructorParamName) .setInfo(sym.owner.outerClass.thisType) MethodType(p :: params, restpe) } else if (restpe ne restpe1) diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala index 171d1df975..bc7d1754d4 100644 --- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala +++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala @@ -165,9 +165,6 @@ abstract class LiftCode extends Transform with TypingTransformers { */ class Reifier() { - final val mirrorFullName = "scala.reflect.mirror" - final val mirrorShortName = "$mr" - final val mirrorPrefix = mirrorShortName + "." final val scalaPrefix = "scala." final val localPrefix = "$local" final val memoizerName = "$memo" @@ -217,16 +214,20 @@ abstract class LiftCode extends Transform with TypingTransformers { // helper methods - private def localName(sym: Symbol) = localPrefix + symIndex(sym) + private def localName(sym: Symbol): TermName = + newTermName(localPrefix + symIndex(sym)) private def call(fname: String, args: Tree*): Tree = Apply(termPath(fname), args.toList) private def mirrorSelect(name: String): Tree = - termPath(mirrorPrefix + name) + termPath(nme.MIRROR_PREFIX + name) + + private def mirrorCall(name: TermName, args: Tree*): Tree = + call("" + (nme.MIRROR_PREFIX append name), args: _*) private def mirrorCall(name: String, args: Tree*): Tree = - call(mirrorPrefix + name, args: _*) + call(nme.MIRROR_PREFIX + name, args: _*) private def mirrorFactoryCall(value: Product, args: Tree*): Tree = mirrorCall(value.productPrefix, args: _*) @@ -322,15 +323,15 @@ abstract class LiftCode extends Transform with TypingTransformers { * Generate code to add type and annotation info to a reified symbol */ private def fillInSymbol(sym: Symbol): Tree = { - val rset = Apply(Select(reifySymRef(sym), "setTypeSig"), List(reifyType(sym.info))) + val rset = Apply(Select(reifySymRef(sym), nme.setTypeSig), List(reifyType(sym.info))) if (sym.annotations.isEmpty) rset - else Apply(Select(rset, "setAnnotations"), List(reify(sym.annotations))) + else Apply(Select(rset, nme.setAnnotations), List(reify(sym.annotations))) } /** Reify a scope */ private def reifyScope(scope: Scope): Tree = { scope foreach registerReifiableSymbol - mirrorCall("newScopeWith", scope.toList map reifySymRef: _*) + mirrorCall(nme.newScopeWith, scope.toList map reifySymRef: _*) } /** Reify a list of symbols that need to be created */ @@ -348,14 +349,14 @@ abstract class LiftCode extends Transform with TypingTransformers { val tpe = tpe0.normalize val tsym = tpe.typeSymbol if (tsym.isClass && tpe == tsym.typeConstructor && tsym.isStatic) - Select(reifySymRef(tpe.typeSymbol), "asTypeConstructor") + Select(reifySymRef(tpe.typeSymbol), nme.asTypeConstructor) else tpe match { case t @ NoType => reifyMirrorObject(t) case t @ NoPrefix => reifyMirrorObject(t) case tpe @ ThisType(clazz) if clazz.isModuleClass && clazz.isStatic => - mirrorCall("thisModuleType", reify(clazz.fullName)) + mirrorCall(nme.thisModuleType, reify(clazz.fullName)) case t @ RefinedType(parents, decls) => registerReifiableSymbol(tpe.typeSymbol) mirrorFactoryCall(t, reify(parents), reify(decls), reify(t.typeSymbol)) @@ -387,13 +388,13 @@ abstract class LiftCode extends Transform with TypingTransformers { case tt: TypeTree if (tt.tpe != null) => if (!(boundSyms exists (tt.tpe contains _))) mirrorCall("TypeTree", reifyType(tt.tpe)) else if (tt.original != null) reify(tt.original) - else mirrorCall("TypeTree") + else mirrorCall(nme.TypeTree) case ta @ TypeApply(hk, ts) => val thereAreOnlyTTs = ts collect { case t if !t.isInstanceOf[TypeTree] => t } isEmpty; val ttsAreNotEssential = ts collect { case tt: TypeTree => tt } find { tt => tt.original != null } isEmpty; if (thereAreOnlyTTs && ttsAreNotEssential) reifyTree(hk) else reifyProduct(ta) case global.emptyValDef => - mirrorSelect("emptyValDef") + mirrorSelect(nme.emptyValDef) case _ => if (tree.isDef) boundSyms += tree.symbol @@ -403,8 +404,8 @@ abstract class LiftCode extends Transform with TypingTransformers { if (tree.isDef || tree.isInstanceOf[Function]) registerReifiableSymbol(tree.symbol) if (tree.hasSymbol) - rtree = Apply(Select(rtree, "setSymbol"), List(reifySymRef(tree.symbol))) - Apply(Select(rtree, "setType"), List(reifyType(tree.tpe))) + rtree = Apply(Select(rtree, nme.setSymbol), List(reifySymRef(tree.symbol))) + Apply(Select(rtree, nme.setType), List(reifyType(tree.tpe))) */ } @@ -413,7 +414,7 @@ abstract class LiftCode extends Transform with TypingTransformers { * to a global value, or else a mirror Literal. */ private def reifyFree(tree: Tree): Tree = - mirrorCall("Ident", reifySymRef(tree.symbol)) + mirrorCall(nme.Ident, reifySymRef(tree.symbol)) // todo: consider whether we should also reify positions private def reifyPosition(pos: Position): Tree = @@ -443,7 +444,7 @@ abstract class LiftCode extends Transform with TypingTransformers { case sym: Symbol => reifySymRef(sym) case tpe: Type => reifyType(tpe) case xs: List[_] => reifyList(xs) - case xs: Array[_] => scalaFactoryCall("Array", xs map reify: _*) + case xs: Array[_] => scalaFactoryCall(nme.Array, xs map reify: _*) case scope: Scope => reifyScope(scope) case x: Name => reifyName(x) case x: Position => reifyPosition(x) @@ -475,7 +476,7 @@ abstract class LiftCode extends Transform with TypingTransformers { private def typePath(fullname: String): Tree = path(fullname, newTypeName) private def mirrorAlias = - ValDef(NoMods, mirrorShortName, TypeTree(), termPath(mirrorFullName)) + ValDef(NoMods, nme.MIRROR_SHORT, TypeTree(), termPath(fullnme.MirrorPackage)) /** * Generate code that generates a symbol table of all symbols registered in `reifiableSyms` diff --git a/src/compiler/scala/tools/nsc/transform/TailCalls.scala b/src/compiler/scala/tools/nsc/transform/TailCalls.scala index ca16e491e2..e2cd0a8402 100644 --- a/src/compiler/scala/tools/nsc/transform/TailCalls.scala +++ b/src/compiler/scala/tools/nsc/transform/TailCalls.scala @@ -128,7 +128,7 @@ abstract class TailCalls extends Transform { * the label field. */ this.label = { - val label = method.newLabel(method.pos, "_" + method.name) + val label = method.newLabel(method.pos, newTermName("_" + method.name)) val thisParam = method.newSyntheticValueParam(currentClass.typeOfThis) label setInfo MethodType(thisParam :: method.tpe.params, method.tpe.finalResultType) } diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 13516037f5..adb408f7e4 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -357,7 +357,7 @@ abstract class UnCurry extends InfoTransform case Apply(Apply(TypeApply(Select(tgt, nme.runOrElse), targs), args_scrut), args_pm) if opt.virtPatmat => object noOne extends Transformer { override val treeCopy = newStrictTreeCopier // must duplicate everything - val one = tgt.tpe member "one".toTermName + val one = tgt.tpe member newTermName("one") override def transform(tree: Tree): Tree = tree match { case Apply(fun, List(a)) if fun.symbol == one => // blow one's argument away since all we want to know is whether the match succeeds or not @@ -367,7 +367,7 @@ abstract class UnCurry extends InfoTransform super.transform(tree) } } - substTree(Apply(Apply(TypeApply(Select(tgt.duplicate, tgt.tpe.member("isSuccess".toTermName)), targs map (_.duplicate)), args_scrut map (_.duplicate)), args_pm map (noOne.transform))) + substTree(Apply(Apply(TypeApply(Select(tgt.duplicate, tgt.tpe.member(newTermName("isSuccess"))), targs map (_.duplicate)), args_scrut map (_.duplicate)), args_pm map (noOne.transform))) // for the optimized version of virtpatmat case Block((zero: ValDef) :: (x: ValDef) :: (matchRes: ValDef) :: (keepGoing: ValDef) :: stats, _) if opt.virtPatmat => dupVirtMatch(zero, x, matchRes, keepGoing, stats) @@ -452,7 +452,7 @@ abstract class UnCurry extends InfoTransform atPhase(phase.next) { if (isJava && isPrimitiveArray(suffix.tpe) && isArrayOfSymbol(fun.tpe.params.last.tpe, ObjectClass)) { suffix = localTyper.typedPos(pos) { - gen.mkRuntimeCall("toObjectArray", List(suffix)) + gen.mkRuntimeCall(nme.toObjectArray, List(suffix)) } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 77dde88a80..3b90eaeed7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -214,10 +214,10 @@ trait Implicits { /** An extractor for types of the form ? { name: (? >: argtpe <: Any*)restp } */ object HasMethodMatching { + val dummyMethod = new TermSymbol(NoSymbol, NoPosition, newTermName("typer$dummy")) + def templateArgType(argtpe: Type) = new BoundedWildcardType(TypeBounds.lower(argtpe)) + def apply(name: Name, argtpes: List[Type], restpe: Type): Type = { - def templateArgType(argtpe: Type) = - new BoundedWildcardType(TypeBounds(argtpe, AnyClass.tpe)) - val dummyMethod = new TermSymbol(NoSymbol, NoPosition, "typer$dummy") val mtpe = MethodType(dummyMethod.newSyntheticValueParams(argtpes map templateArgType), restpe) memberWildcardType(name, mtpe) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index 99ba0e0971..b9264aae55 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -7,13 +7,10 @@ trait Macros { self: Analyzer => import global._ import definitions._ - def macroMethName(name: Name) = - newTermName((if (name.isTypeName) "type" else "def") + "macro$" + name) - def macroMeth(mac: Symbol): Symbol = { var owner = mac.owner if (!owner.isModuleClass) owner = owner.companionModule.moduleClass - owner.info.decl(macroMethName(mac.name)) + owner.info.decl(nme.macroMethodName(mac.name)) } /** @@ -37,21 +34,21 @@ trait Macros { self: Analyzer => def macroMethDef(mdef: DefDef): Tree = { def paramDef(name: Name, tpt: Tree) = ValDef(Modifiers(PARAM), name, tpt, EmptyTree) val universeType = TypeTree(ReflectApiUniverse.tpe) - val globParamSec = List(paramDef("glob", universeType)) - def globSelect(name: Name) = Select(Ident("glob"), name) + val globParamSec = List(paramDef(nme.glob, universeType)) + def globSelect(name: Name) = Select(Ident(nme.glob), name) def globTree = globSelect(newTypeName("Tree")) def globType = globSelect(newTypeName("Type")) - val thisParamSec = if (mdef.symbol.owner.isModuleClass) List() else List(paramDef("_this", globTree)) + val thisParamSec = if (mdef.symbol.owner.isModuleClass) List() else List(paramDef(newTermName("_this"), globTree)) def tparamInMacro(tdef: TypeDef) = paramDef(tdef.name.toTermName, globType) def vparamInMacro(vdef: ValDef): ValDef = paramDef(vdef.name, globTree) def wrapImplicit(tree: Tree) = atPos(tree.pos) { - Block(List(ValDef(Modifiers(IMPLICIT), "$glob", universeType, Ident("glob"))), tree) + Block(List(ValDef(Modifiers(IMPLICIT), newTermName("$" + nme.glob), universeType, Ident(nme.glob))), tree) } atPos(mdef.pos) { new DefDef( // can't call DefDef here; need to find out why mods = mdef.mods &~ MACRO, - name = macroMethName(mdef.name), + name = nme.macroMethodName(mdef.name), tparams = List(), vparamss = globParamSec :: thisParamSec :: (mdef.tparams map tparamInMacro) :: (mdef.vparamss map (_ map vparamInMacro)), diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 7c605fa0a1..62393befd2 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -248,7 +248,7 @@ trait MethodSynthesis { } sealed abstract class BeanAccessor(bean: String) extends DerivedFromValDef { - def name = bean + tree.name.toString.capitalize + val name = newTermName(bean + tree.name.toString.capitalize) def flagsMask = BeanPropertyFlags def flagsExtra = 0 override def derivedSym = enclClass.info decl name diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index a20461949d..200191fa13 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -579,7 +579,7 @@ trait Namers extends MethodSynthesis { // via "x$lzy" as can be seen in test #3927. val sym = ( if (owner.isClass) createFieldSymbol(tree) - else owner.newValue(tree.pos, tree.name + "$lzy") setFlag tree.mods.flags resetFlag IMPLICIT + else owner.newValue(tree.pos, tree.name append nme.LAZY_LOCAL) setFlag tree.mods.flags resetFlag IMPLICIT ) enterValSymbol(tree, sym setFlag MUTABLE setLazyAccessor lazyAccessor) } diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala index 75a5ad6f8a..440db4300c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala @@ -46,8 +46,6 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => import global._ import definitions._ - private lazy val matchingStrategyTycon = definitions.getClass("scala.MatchingStrategy").typeConstructor - class MatchTranslator(typer: Typer) extends MatchCodeGen { def typed(tree: Tree, mode: Int, pt: Type): Tree = typer.typed(tree, mode, pt) // for MatchCodeGen -- imports don't provide implementations for abstract members @@ -55,7 +53,7 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => import typeDebug.{ ptTree, ptBlock, ptLine } def solveContextBound(contextBoundTp: Type): (Tree, Type) = { - val solSym = NoSymbol.newTypeParameter(NoPosition, "SolveImplicit$".toTypeName) + val solSym = NoSymbol.newTypeParameter(NoPosition, newTypeName("SolveImplicit$")) val param = solSym.setInfo(contextBoundTp.typeSymbol.typeParams(0).info.cloneInfo(solSym)) // TypeBounds(NothingClass.typeConstructor, baseTp) val pt = appliedType(contextBoundTp, List(param.tpeHK)) val savedUndets = context.undetparams @@ -67,7 +65,7 @@ trait PatMatVirtualiser extends ast.TreeDSL { self: Analyzer => (result.tree, result.subst.to(result.subst.from indexOf param)) } - lazy val (matchingStrategy, matchingMonadType) = solveContextBound(matchingStrategyTycon) + lazy val (matchingStrategy, matchingMonadType) = solveContextBound(MatchingStrategyClass.typeConstructor) /** Implement a pattern match by turning its cases (including the implicit failure case) * into the corresponding (monadic) extractors, and combining them with the `orElse` combinator. @@ -1482,19 +1480,18 @@ defined class Foo */ } object vpmName { - val one = "one".toTermName - val drop = "drop".toTermName - val flatMap = "flatMap".toTermName - val get = "get".toTermName - val guard = "guard".toTermName - val isEmpty = "isEmpty".toTermName - val orElse = "orElse".toTermName - val outer = "<outer>".toTermName - val runOrElse = "runOrElse".toTermName - val zero = "zero".toTermName - - def counted(str: String, i: Int) = (str+i).toTermName - def tupleIndex(i: Int) = ("_"+i).toTermName + val one = newTermName("one") + val drop = newTermName("drop") + val flatMap = newTermName("flatMap") + val get = newTermName("get") + val guard = newTermName("guard") + val isEmpty = newTermName("isEmpty") + val orElse = newTermName("orElse") + val outer = newTermName("<outer>") + val runOrElse = newTermName("runOrElse") + val zero = newTermName("zero") + + def counted(str: String, i: Int) = newTermName(str+i) } @@ -1503,7 +1500,7 @@ defined class Foo */ trait CommonCodeGen extends AbsCodeGen { self: CommonCodeGen with MatchingStrategyGen with MonadInstGen => def fun(arg: Symbol, body: Tree): Tree = Function(List(ValDef(arg)), body) def genTypeApply(tfun: Tree, args: Type*): Tree = if(args contains NoType) tfun else TypeApply(tfun, args.toList map TypeTree) - def tupleSel(binder: Symbol)(i: Int): Tree = (REF(binder) DOT vpmName.tupleIndex(i)) // make tree that accesses the i'th component of the tuple referenced by binder + def tupleSel(binder: Symbol)(i: Int): Tree = (REF(binder) DOT nme.productAccessorName(i)) // make tree that accesses the i'th component of the tuple referenced by binder def index(tgt: Tree)(i: Int): Tree = tgt APPLY (LIT(i)) def drop(tgt: Tree)(n: Int): Tree = (tgt DOT vpmName.drop) (LIT(n)) def _equals(checker: Tree, binder: Symbol): Tree = checker MEMBER_== REF(binder) // NOTE: checker must be the target of the ==, that's the patmat semantics for ya 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) = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index a7ad140fc1..5ccf27ded9 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3478,7 +3478,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { case ex: TypeError => fun match { case Select(qual, name) - if !isPatternMode && nme.isOpAssignmentName(name.decode) => + if !isPatternMode && nme.isOpAssignmentName(newTermName(name.decode)) => val qual1 = typedQualifier(qual) if (treeInfo.isVariableOrGetter(qual1)) { stopTimer(failedOpEqNanos, opeqStart) diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index 9b69c847f6..fd6f972ffc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -21,6 +21,8 @@ trait Unapplies extends ast.TreeDSL import CODE.{ CASE => _, _ } import treeInfo.{ isRepeatedParamType, isByNameParamType } + private val unapplyParamName = newTermName("x$0") + /** returns type list for return type of the extraction */ def unapplyTypeList(ufn: Symbol, ufntpe: Type) = { assert(ufn.isMethod) @@ -173,14 +175,13 @@ trait Unapplies extends ast.TreeDSL */ def caseModuleUnapplyMeth(cdef: ClassDef): DefDef = { val tparams = cdef.tparams map copyUntypedInvariant - val paramName = newTermName("x$0") val method = constrParamss(cdef) match { case xs :: _ if xs.nonEmpty && isRepeatedParamType(xs.last.tpt) => nme.unapplySeq case _ => nme.unapply } - val cparams = List(ValDef(Modifiers(PARAM | SYNTHETIC), paramName, classType(cdef, tparams), EmptyTree)) + val cparams = List(ValDef(Modifiers(PARAM | SYNTHETIC), unapplyParamName, classType(cdef, tparams), EmptyTree)) val ifNull = if (constrParamss(cdef).head.isEmpty) FALSE else REF(NoneModule) - val body = nullSafe({ case Ident(x) => caseClassUnapplyReturnValue(x, cdef.symbol) }, ifNull)(Ident(paramName)) + val body = nullSafe({ case Ident(x) => caseClassUnapplyReturnValue(x, cdef.symbol) }, ifNull)(Ident(unapplyParamName)) atPos(cdef.pos.focus)( DefDef(caseMods, method, tparams, List(cparams), TypeTree(), body) diff --git a/src/compiler/scala/tools/nsc/util/ProxyReport.scala b/src/compiler/scala/tools/nsc/util/ProxyReport.scala index 86cf2006bb..2f4f029308 100644 --- a/src/compiler/scala/tools/nsc/util/ProxyReport.scala +++ b/src/compiler/scala/tools/nsc/util/ProxyReport.scala @@ -13,7 +13,7 @@ import scala.collection.{ mutable, immutable, generic } trait ProxyReport { val global: Global import global._ - import definitions.{ getClass => gc, _ } + import definitions._ private object classes { def isIgnorable(sym: Symbol) = sym :: sym.allOverriddenSymbols exists { s => @@ -26,13 +26,13 @@ trait ProxyReport { methods foreach (m => m.initialize.info.paramss.flatten foreach (_.initialize)) methods } - lazy val GlobalClass = gc(classOf[Global].getName) - lazy val GenericClass = getModule("scala.collection.generic").moduleClass - lazy val CollectionClass = getModule("scala.collection").moduleClass + lazy val GlobalClass = getRequiredClass(classOf[Global].getName) + lazy val GenericClass = getRequiredModule("scala.collection.generic").moduleClass + lazy val CollectionClass = getRequiredModule("scala.collection").moduleClass - def getType(name: String) = getMember(GlobalClass, name.toTypeName) - def getColl(name: String) = getMember(CollectionClass, name.toTypeName) - def getGeneric(name: String) = getMember(GenericClass, name.toTypeName) + def getType(name: String) = getMember(GlobalClass, newTypeName(name)) + def getColl(name: String) = getMember(CollectionClass, newTypeName(name)) + def getGeneric(name: String) = getMember(GenericClass, newTypeName(name)) // the following operations + those in RewrappingTypeProxy are all operations // in class Type that are overridden in some subclass |