summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/CompilationUnits.scala3
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala24
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala8
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala29
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala160
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Scanners.scala8
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala66
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala38
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala44
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala3
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala44
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaScanners.scala4
-rw-r--r--src/compiler/scala/tools/nsc/matching/Matrix.scala8
-rw-r--r--src/compiler/scala/tools/nsc/matching/ParallelMatching.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala135
-rw-r--r--src/compiler/scala/tools/nsc/symtab/NameManglers.scala13
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Names.scala105
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala801
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala6
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala94
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala6
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala86
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala15
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/AddInterfaces.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala18
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala6
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/DeVirtualize.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala36
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala25
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala10
-rw-r--r--src/compiler/scala/tools/nsc/util/FreshNameCreator.scala10
-rwxr-xr-xsrc/library/scala/reflect/generic/Names.scala45
-rwxr-xr-xsrc/library/scala/reflect/generic/StdNames.scala51
-rwxr-xr-xsrc/library/scala/reflect/generic/Symbols.scala18
-rwxr-xr-xsrc/library/scala/reflect/generic/Trees.scala32
-rwxr-xr-xsrc/library/scala/reflect/generic/UnPickler.scala2
-rw-r--r--src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala2
-rw-r--r--test/files/pos/spec-Function1.scala1
50 files changed, 1063 insertions, 951 deletions
diff --git a/src/compiler/scala/tools/nsc/CompilationUnits.scala b/src/compiler/scala/tools/nsc/CompilationUnits.scala
index 3c5e033c74..d3dae52895 100644
--- a/src/compiler/scala/tools/nsc/CompilationUnits.scala
+++ b/src/compiler/scala/tools/nsc/CompilationUnits.scala
@@ -18,6 +18,9 @@ trait CompilationUnits { self: Global =>
/** the fresh name creator */
var fresh: FreshNameCreator = new FreshNameCreator.Default
+ def freshTermName(prefix: String): TermName = newTermName(fresh.newName(prefix))
+ def freshTypeName(prefix: String): TypeName = newTypeName(fresh.newName(prefix))
+
/** the content of the compilation unit in tree form */
var body: Tree = EmptyTree
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 1ac2c3442a..d93496a7c4 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -22,11 +22,11 @@ abstract class TreeGen {
def rootId(name: Name) = Select(Ident(nme.ROOTPKG), name)
def rootScalaDot(name: Name) = Select(rootId(nme.scala_) setSymbol ScalaPackage, name)
def scalaDot(name: Name) = Select(Ident(nme.scala_) setSymbol ScalaPackage, name)
- def scalaAnyRefConstr = scalaDot(nme.AnyRef.toTypeName)
- def scalaUnitConstr = scalaDot(nme.Unit.toTypeName)
- def scalaScalaObjectConstr = scalaDot(nme.ScalaObject.toTypeName)
- def productConstr = scalaDot(nme.Product.toTypeName)
- def serializableConstr = scalaDot(nme.Serializable.toTypeName)
+ def scalaAnyRefConstr = scalaDot(tpnme.AnyRef)
+ def scalaUnitConstr = scalaDot(tpnme.Unit)
+ def scalaScalaObjectConstr = scalaDot(tpnme.ScalaObject)
+ def productConstr = scalaDot(tpnme.Product)
+ def serializableConstr = scalaDot(tpnme.Serializable)
private def isRootOrEmptyPackageClass(s: Symbol) = s.isRoot || s.isEmptyPackageClass
@@ -317,7 +317,7 @@ abstract class TreeGen {
Apply(Select(monitor, Object_synchronized), List(body))
def wildcardStar(tree: Tree) =
- atPos(tree.pos) { Typed(tree, Ident(nme.WILDCARD_STAR)) }
+ atPos(tree.pos) { Typed(tree, Ident(tpnme.WILDCARD_STAR)) }
def paramToArg(vparam: Symbol) = {
val arg = Ident(vparam)
@@ -363,12 +363,12 @@ abstract class TreeGen {
/** Try to convert Select(qual, name) to a SelectFromTypeTree.
*/
- def convertToSelectFromType(qual: Tree, name: Name): Tree = {
- def selFromType(qual1: Tree) = SelectFromTypeTree(qual1 setPos qual.pos, name)
+ def convertToSelectFromType(qual: Tree, origName: Name): Tree = {
+ def selFromType(qual1: Tree) = SelectFromTypeTree(qual1 setPos qual.pos, origName)
qual match {
case Select(qual1, name) => selFromType(Select(qual1, name.toTypeName))
- case Ident(name) => selFromType(Ident(name.toTypeName))
- case _ => EmptyTree
+ case Ident(name) => selFromType(Ident(name.toTypeName))
+ case _ => EmptyTree
}
}
@@ -379,7 +379,7 @@ abstract class TreeGen {
if (treeInfo.isPureExpr(expr)) {
within(() => if (used) expr.duplicate else { used = true; expr })
} else {
- val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName("ev$"))
+ val temp = owner.newValue(expr.pos.makeTransparent, unit.freshTermName("ev$"))
.setFlag(SYNTHETIC).setInfo(expr.tpe)
val containing = within(() => Ident(temp) setPos temp.pos.focus setType expr.tpe)
ensureNonOverlapping(containing, List(expr))
@@ -399,7 +399,7 @@ abstract class TreeGen {
() => if (used(idx)) expr.duplicate else { used(idx) = true; expr }
}
} else {
- val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName("ev$"))
+ val temp = owner.newValue(expr.pos.makeTransparent, unit.freshTermName("ev$"))
.setFlag(SYNTHETIC).setInfo(expr.tpe)
vdefs += ValDef(temp, expr)
exprs1 += (() => Ident(temp) setPos temp.pos.focus setType expr.tpe)
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
index 8be793343e..8e663c32dd 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala
@@ -176,15 +176,15 @@ abstract class TreeInfo {
/** Is tpt of the form T* ? */
def isRepeatedParamType(tpt: Tree) = tpt match {
case TypeTree() => definitions.isRepeatedParamType(tpt.tpe)
- case AppliedTypeTree(Select(_, nme.REPEATED_PARAM_CLASS_NAME), _) => true
- case AppliedTypeTree(Select(_, nme.JAVA_REPEATED_PARAM_CLASS_NAME), _) => true
+ case AppliedTypeTree(Select(_, tpnme.REPEATED_PARAM_CLASS_NAME), _) => true
+ case AppliedTypeTree(Select(_, tpnme.JAVA_REPEATED_PARAM_CLASS_NAME), _) => true
case _ => false
}
/** Is tpt a by-name parameter type? */
def isByNameParamType(tpt: Tree) = tpt match {
case TypeTree() => definitions.isByNameParamType(tpt.tpe)
- case AppliedTypeTree(Select(_, nme.BYNAME_PARAM_CLASS_NAME), _) => true
+ case AppliedTypeTree(Select(_, tpnme.BYNAME_PARAM_CLASS_NAME), _) => true
case _ => false
}
@@ -217,7 +217,7 @@ abstract class TreeInfo {
/** Is this argument node of the form <expr> : _* ?
*/
def isWildcardStarArg(tree: Tree): Boolean = tree match {
- case Typed(_, Ident(nme.WILDCARD_STAR)) => true
+ case Typed(_, Ident(tpnme.WILDCARD_STAR)) => true
case _ => false
}
def isWildcardStarArgList(trees: List[Tree]) =
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index ad73d45dd0..293c32c8a5 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -17,6 +17,8 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
var body: Tree
val source: SourceFile
def fresh : FreshNameCreator
+ def freshTermName(prefix: String): TermName
+ def freshTypeName(prefix: String): TypeName
}
type CompilationUnit <: CompilationUnitTrait
@@ -36,25 +38,24 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
implicit def treeWrapper(tree: Tree): TreeOps = new TreeOps(tree)
class TreeOps(tree: Tree) {
-
def isTerm: Boolean = tree match {
- case _: TermTree => true
- case Bind(name, _) => name.isTermName
- case Select(_, name) => name.isTermName
- case Ident(name) => name.isTermName
+ case _: TermTree => true
+ case Bind(name, _) => name.isTermName
+ case Select(_, name) => name.isTermName
+ case Ident(name) => name.isTermName
case Annotated(_, arg) => arg.isTerm
- case DocDef(_, defn) => defn.isTerm
- case _ => false
+ case DocDef(_, defn) => defn.isTerm
+ case _ => false
}
def isType: Boolean = tree match {
- case _: TypTree => true
- case Bind(name, _) => name.isTypeName
- case Select(_, name) => name.isTypeName
- case Ident(name) => name.isTypeName
+ case _: TypTree => true
+ case Bind(name, _) => name.isTypeName
+ case Select(_, name) => name.isTypeName
+ case Ident(name) => name.isTypeName
case Annotated(_, arg) => arg.isType
- case DocDef(_, defn) => defn.isType
- case _ => false
+ case DocDef(_, defn) => defn.isType
+ case _ => false
}
def isErroneous = (tree.tpe ne null) && tree.tpe.isErroneous
@@ -254,7 +255,7 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
if (vparamss1.isEmpty || !vparamss1.head.isEmpty && vparamss1.head.head.mods.isImplicit)
vparamss1 = List() :: vparamss1;
val superRef: Tree = atPos(superPos) {
- Select(Super(nme.EMPTY.toTypeName, nme.EMPTY.toTypeName), nme.CONSTRUCTOR)
+ Select(Super(tpnme.EMPTY, tpnme.EMPTY), nme.CONSTRUCTOR)
}
val superCall = (superRef /: argss) (Apply)
List(
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 1ae9a9d8c0..1ffb29809a 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -73,7 +73,9 @@ self =>
val in = new UnitScanner(unit, patches)
in.init()
- def freshName(prefix: String): Name = unit.fresh.newName(prefix)
+ def freshName(prefix: String): Name = freshTermName(prefix)
+ def freshTermName(prefix: String): TermName = unit.freshTermName(prefix)
+ def freshTypeName(prefix: String): TypeName = unit.freshTypeName(prefix)
def o2p(offset: Int): Position = new OffsetPosition(unit.source,offset)
def r2p(start: Int, mid: Int, end: Int): Position = rangePos(unit.source, start, mid, end)
@@ -136,20 +138,15 @@ self =>
final val Local = 0
final val InBlock = 1
final val InTemplate = 2
- final val MINUS: Name = "-"
- final val PLUS : Name = "+"
- final val BANG : Name = "!"
- final val TILDE: Name = "~"
- final val AMP : Name = "&"
- final val SLASH: Name = "/"
- final val STAR : Name = "*"
- final val BAR : Name = "|"
- final val LT : Name = "<"
+
+ import nme.raw
abstract class Parser {
val in: Scanner
def freshName(prefix: String): Name
+ def freshTermName(prefix: String): TermName
+ def freshTypeName(prefix: String): TypeName
def o2p(offset: Int): Position
def r2p(start: Int, mid: Int, end: Int): Position
@@ -158,7 +155,9 @@ self =>
object treeBuilder extends TreeBuilder {
val global: self.global.type = self.global
- def freshName(prefix: String): Name = Parser.this.freshName(prefix)
+ def freshName(prefix: String): Name = freshTermName(prefix)
+ def freshTermName(prefix: String): TermName = Parser.this.freshTermName(prefix)
+ def freshTypeName(prefix: String): TypeName = Parser.this.freshTypeName(prefix)
def o2p(offset: Int) = Parser.this.o2p(offset)
def r2p(start: Int, point: Int, end: Int) = Parser.this.r2p(start, point, end)
}
@@ -258,11 +257,11 @@ self =>
)
// def main
- def mainParamType = AppliedTypeTree(Ident(nme.Array.toTypeName), List(Ident(nme.String.toTypeName)))
+ 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 mainNew = makeNew(Nil, emptyValDef, stmts, List(Nil), NoPosition, NoPosition)
- def mainDef = DefDef(NoMods, nme.main, Nil, List(mainParameter), scalaDot(nme.Unit.toTypeName), Block(mainSetArgv, mainNew))
+ def mainDef = DefDef(NoMods, nme.main, Nil, List(mainParameter), scalaDot(tpnme.Unit), Block(mainSetArgv, mainNew))
// object Main
def moduleName = ScriptRunner scriptMain settings
@@ -488,10 +487,9 @@ self =>
case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => true
case _ => false
}
- def isUnaryOp: Boolean = isIdent && (in.name match {
- case MINUS | PLUS | TILDE | BANG => true
- case _ => false
- })
+ def isUnaryOp = isIdent && raw.isUnary(in.name)
+ def isRawStar = isIdent && in.name == raw.STAR
+ def isRawBar = isIdent && in.name == raw.BAR
def isIdent = in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT
@@ -675,6 +673,7 @@ self =>
/* -------- IDENTIFIERS AND LITERALS ------------------------------------------- */
+ /** Assumed (provisionally) to be TermNames. */
def ident(skipIt: Boolean): Name =
if (in.token == IDENTIFIER || in.token == BACKQUOTED_IDENT) {
val name = in.name.encode
@@ -684,9 +683,12 @@ self =>
syntaxErrorOrIncomplete(expectedMsg(IDENTIFIER), skipIt)
nme.ERROR
}
-
def ident(): Name = ident(true)
+ /** For when it's known already to be a type name. */
+ def identForType(): TypeName = ident().toTypeName
+ def identForType(skipIt: Boolean): TypeName = ident(skipIt).toTypeName
+
def selector(t: Tree): Tree = {
val point = in.offset
//assert(t.pos.isDefined, t)
@@ -702,13 +704,13 @@ self =>
var t: Tree = null
if (in.token == THIS) {
in.nextToken()
- t = atPos(start) { This(nme.EMPTY.toTypeName) }
+ t = atPos(start) { This(tpnme.EMPTY) }
if (!thisOK || in.token == DOT) {
t = selectors(t, typeOK, accept(DOT))
}
} else if (in.token == SUPER) {
in.nextToken()
- t = atPos(start) { Super(nme.EMPTY.toTypeName, mixinQualifierOpt()) }
+ t = atPos(start) { Super(tpnme.EMPTY, mixinQualifierOpt()) }
accept(DOT)
t = selector(t)
if (in.token == DOT) t = selectors(t, typeOK, in.skipToken())
@@ -752,14 +754,14 @@ self =>
/** MixinQualifier ::= `[' Id `]'
*/
- def mixinQualifierOpt(): Name =
+ def mixinQualifierOpt(): TypeName =
if (in.token == LBRACKET) {
in.nextToken()
- val name = ident().toTypeName
+ val name = identForType()
accept(RBRACKET)
name
} else {
- nme.EMPTY.toTypeName
+ tpnme.EMPTY
}
/** StableId ::= Id
@@ -904,8 +906,8 @@ self =>
val opOffset = in.offset
val leftAssoc = treeInfo.isLeftAssoc(in.name)
if (mode != InfixMode.FirstOp) checkAssoc(opOffset, in.name, mode == InfixMode.LeftOp)
- val op = ident()
- val tycon = atPos(opOffset) { Ident(op.toTypeName) }
+ val op = identForType()
+ val tycon = atPos(opOffset) { Ident(op) }
newLineOptWhenFollowing(isTypeIntroToken)
def mkOp(t1: Tree) = atPos(t.pos.startOrPoint, opOffset) { AppliedTypeTree(tycon, List(t, t1)) }
if (leftAssoc)
@@ -985,9 +987,9 @@ self =>
if (in.token == HASH) {
val hashOffset = in.skipToken()
val nameOffset = in.offset
- val name = ident(false)
- val sel = atPos(t.pos.startOrPoint, if (name == nme.ERROR) hashOffset else nameOffset) {
- SelectFromTypeTree(t, name.toTypeName)
+ val name = identForType(false)
+ val sel = atPos(t.pos.startOrPoint, if (name == tpnme.ERROR) hashOffset else nameOffset) {
+ SelectFromTypeTree(t, name)
}
simpleTypeRest(sel, isPattern)
} else if (in.token == LBRACKET) {
@@ -999,7 +1001,7 @@ self =>
/** WildcardType ::= `_' TypeBounds
*/
def wildcardType(start: Int) = {
- val pname = freshName("_$").toTypeName
+ val pname = freshTypeName("_$")
val t = atPos(start) { Ident(pname) }
val bounds = typeBounds()
val param = atPos(t.pos union bounds.pos) { makeSyntheticTypeParam(pname, bounds) }
@@ -1024,9 +1026,9 @@ self =>
if (in.token == USCORE) {
in.nextToken()
if (in.token == SUBTYPE || in.token == SUPERTYPE) wildcardType(start)
- else atPos(start) { Bind(nme.WILDCARD.toTypeName, EmptyTree) }
- } else if (in.token == IDENTIFIER && treeInfo.isVariableName(in.name.toTypeName)) {
- atPos(start) { Bind(ident().toTypeName, EmptyTree) }
+ else atPos(start) { Bind(tpnme.WILDCARD, EmptyTree) }
+ } else if (in.token == IDENTIFIER && treeInfo.isVariableName(in.name)) {
+ atPos(start) { Bind(identForType(), EmptyTree) }
} else {
typ(true)
}
@@ -1034,12 +1036,12 @@ self =>
// copy-paste (with change) from def paramType
if (in.token == ARROW) {
in.nextToken()
- val tycon = atPos(start) { rootScalaDot(nme.BYNAME_PARAM_CLASS_NAME) }
+ val tycon = atPos(start) { rootScalaDot(tpnme.BYNAME_PARAM_CLASS_NAME) }
atPos(start) { AppliedTypeTree(tycon, List(typ())) }
} else {
val t = typ()
- if (isIdent && in.name == STAR) {
- val tycon = atPos(in.skipToken()) { rootScalaDot(nme.REPEATED_PARAM_CLASS_NAME) }
+ if (isRawStar) {
+ val tycon = atPos(in.skipToken()) { rootScalaDot(tpnme.REPEATED_PARAM_CLASS_NAME) }
atPos(start) { AppliedTypeTree(tycon, List(t)) }
} else t
}
@@ -1138,7 +1140,7 @@ self =>
case WHILE =>
val start = in.offset
atPos(in.skipToken()) {
- val lname: Name = freshName(nme.WHILE_PREFIX)
+ val lname: Name = freshTermName(nme.WHILE_PREFIX)
val cond = condExpr()
newLinesOpt()
val body = expr()
@@ -1147,7 +1149,7 @@ self =>
case DO =>
val start = in.offset
atPos(in.skipToken()) {
- val lname: Name = freshName(nme.DO_WHILE_PREFIX)
+ val lname: Name = freshTermName(nme.DO_WHILE_PREFIX)
val body = expr()
if (isStatSep) in.nextToken()
accept(WHILE)
@@ -1193,7 +1195,7 @@ self =>
if (isIdent && in.name == nme.STAR) {
in.nextToken()
t = atPos(t.pos.startOrPoint, colonPos) {
- Typed(t, atPos(uscorePos) { Ident(nme.WILDCARD_STAR) })
+ Typed(t, atPos(uscorePos) { Ident(tpnme.WILDCARD_STAR) })
}
} else {
syntaxErrorOrIncomplete("`*' expected", true)
@@ -1299,7 +1301,7 @@ self =>
if (isUnaryOp) {
atPos(in.offset) {
val name: Name = "unary_" + ident()
- if (in.name == MINUS && isNumericLit) simpleExprRest(atPos(in.offset)(literal(true)), true)
+ if (in.name == raw.MINUS && isNumericLit) simpleExprRest(atPos(in.offset)(literal(true)), true)
else Select(stripParens(simpleExpr()), name)
}
}
@@ -1523,9 +1525,9 @@ self =>
def pattern(seqOK: Boolean): Tree = {
val start = in.offset
val t = pattern1(seqOK)
- if (isIdent && in.name == BAR) {
+ if (isRawBar) {
val ts = new ListBuffer[Tree] += t
- while (isIdent && in.name == BAR) {
+ while (isRawBar) {
in.nextToken(); ts += pattern1(seqOK)
}
atPos(start) { makeAlternative(ts.toList) }
@@ -1558,22 +1560,16 @@ self =>
*/
def pattern2(seqOK: Boolean): Tree = {
val p = pattern3(seqOK)
- if (in.token == AT) {
- p match {
- case Ident(name) =>
- if (name == nme.WILDCARD) {
- in.nextToken()
- pattern3(seqOK)
- } else if (treeInfo.isVarPattern(p)) {
- in.nextToken()
- atPos(p.pos.startOrPoint) { Bind(name, pattern3(seqOK)) }
- } else {
- p
- }
- case _ =>
- p
- }
- } else p
+ if (in.token != AT) p
+ else p match {
+ case Ident(nme.WILDCARD) =>
+ in.nextToken()
+ pattern3(seqOK)
+ case Ident(name) if treeInfo.isVarPattern(p) =>
+ in.nextToken()
+ atPos(p.pos.startOrPoint) { Bind(name, pattern3(seqOK)) }
+ case _ => p
+ }
}
/* Pattern3 ::= SimplePattern
@@ -1587,10 +1583,10 @@ self =>
// See ticket #3189 for the motivation for the null check.
// TODO: dredge out the remnants of regexp patterns.
// ... and now this is back the way it was because it caused #3480.
- if (seqOK && isIdent && in.name == STAR)
+ if (seqOK && isRawStar)
return atPos(top.pos.startOrPoint, in.skipToken())(Star(stripParens(top)))
- while (isIdent && in.name != BAR) {
+ while (isIdent && in.name != raw.BAR) {
top = reduceStack(
false, base, top, precedence(in.name), treeInfo.isLeftAssoc(in.name))
val op = in.name
@@ -1627,7 +1623,7 @@ self =>
in.token match {
case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT =>
t match {
- case Ident(name) if name == nme.MINUS =>
+ case Ident(nme.MINUS) =>
return atPos(start) { literal(true) }
case _ =>
}
@@ -1699,7 +1695,7 @@ self =>
if (mods.hasAccessBoundary)
syntaxError("duplicate private/protected qualifier", false)
result = if (in.token == THIS) { in.nextToken(); mods | Flags.LOCAL }
- else Modifiers(mods.flags, ident().toTypeName)
+ else Modifiers(mods.flags, identForType())
accept(RBRACKET)
}
result
@@ -1912,15 +1908,15 @@ self =>
if (in.token == ARROW) {
atPos(in.skipToken()) {
AppliedTypeTree(
- rootScalaDot(nme.BYNAME_PARAM_CLASS_NAME), List(typ()))
+ rootScalaDot(tpnme.BYNAME_PARAM_CLASS_NAME), List(typ()))
}
} else {
val t = typ()
- if (isIdent && in.name == STAR) {
+ if (isRawStar) {
in.nextToken()
atPos(t.pos.startOrPoint, t.pos.point) {
AppliedTypeTree(
- rootScalaDot(nme.REPEATED_PARAM_CLASS_NAME), List(t))
+ rootScalaDot(tpnme.REPEATED_PARAM_CLASS_NAME), List(t))
}
} else t
}
@@ -1937,20 +1933,20 @@ self =>
var mods = ms | Flags.PARAM
val start = in.offset
if (owner.isTypeName && isIdent) {
- if (in.name == PLUS) {
+ if (in.name == raw.PLUS) {
in.nextToken()
mods |= Flags.COVARIANT
- } else if (in.name == MINUS) {
+ } else if (in.name == raw.MINUS) {
in.nextToken()
mods |= Flags.CONTRAVARIANT
}
}
val nameOffset = in.offset
- val pname =
+ val pname: TypeName =
(if (in.token == USCORE) { // TODO AM: freshName(o2p(in.skipToken()), "_$$"), will need to update test suite
in.nextToken()
- nme.WILDCARD
- } else ident()).toTypeName
+ tpnme.WILDCARD
+ } else identForType())
val param = atPos(start, nameOffset) {
val tparams = typeParamClauseOpt(pname, null) // @M TODO null --> no higher-order context bounds for now
TypeDef(mods, pname, tparams, typeBounds())
@@ -1987,15 +1983,15 @@ self =>
*/
def typeBounds(): TypeBoundsTree = {
val t = TypeBoundsTree(
- bound(SUPERTYPE, nme.Nothing),
- bound(SUBTYPE, nme.Any))
+ bound(SUPERTYPE, tpnme.Nothing),
+ bound(SUBTYPE, tpnme.Any))
t setPos (wrappingPos(List(t.hi, t.lo)))
t
}
- def bound(tok: Int, default: Name): Tree =
+ def bound(tok: Int, default: TypeName): Tree =
if (in.token == tok) { in.nextToken(); typ() }
- else atPos(o2p(in.lastOffset)) { rootScalaDot(default.toTypeName) }
+ else atPos(o2p(in.lastOffset)) { rootScalaDot(default) }
/* -------- DEFS ------------------------------------------- */
@@ -2021,7 +2017,7 @@ self =>
var t: Tree = null
if (in.token == THIS) {
in.nextToken()
- t = atPos(start) { This(nme.EMPTY.toTypeName) }
+ t = atPos(start) { This(tpnme.EMPTY) }
accept(DOT)
t = selector(t)
accept(DOT)
@@ -2315,7 +2311,7 @@ self =>
in.nextToken
newLinesOpt()
atPos(start, in.offset) {
- val name = ident().toTypeName
+ val name = identForType()
// @M! a type alias as well as an abstract type may declare type parameters
val tparams = typeParamClauseOpt(name, null)
in.token match {
@@ -2369,8 +2365,9 @@ self =>
def classDef(start: Int, mods: Modifiers): ClassDef = {
in.nextToken
val nameOffset = in.offset
- val name = ident().toTypeName
- atPos(start, if (name == nme.ERROR.toTypeName) start else nameOffset) {
+ val name = identForType()
+
+ atPos(start, if (name == tpnme.ERROR) start else nameOffset) {
val savedContextBounds = classContextBounds
val contextBoundBuf = new ListBuffer[Tree]
val tparams = typeParamClauseOpt(name, contextBoundBuf)
@@ -2411,7 +2408,7 @@ self =>
val tstart = in.offset
atPos(start, if (name == nme.ERROR) start else nameOffset) {
val mods1 = if (in.token == SUBTYPE) mods | Flags.DEFERRED else mods
- val template = templateOpt(mods1, name, NoMods, List(), tstart)
+ val template = templateOpt(mods1, name, NoMods, Nil, tstart)
ModuleDef(mods1, name, template)
}
}
@@ -2474,8 +2471,7 @@ self =>
* TraitTemplateOpt ::= TraitExtends TraitTemplate | [['extends'] TemplateBody] | '<:' TemplateBody
* TraitExtends ::= 'extends' | `<:'
*/
- def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers,
- vparamss: List[List[ValDef]], tstart: Int): Template = {
+ def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]], tstart: Int): Template = {
val (parents0, argss, self, body) =
if (in.token == EXTENDS || settings.YvirtClasses && mods.hasTraitFlag && in.token == SUBTYPE) {
in.nextToken()
@@ -2489,7 +2485,7 @@ self =>
(List(), List(List()), self, body)
}
var parents = parents0
- if (!isInterface(mods, body) && !(inScalaPackage && name == nme.Array.toTypeName))
+ if (!isInterface(mods, body) && !(inScalaPackage && name == tpnme.Array))
parents = parents ::: List(scalaScalaObjectConstr)
if (parents.isEmpty)
parents = List(scalaAnyRefConstr)
@@ -2628,7 +2624,7 @@ self =>
val first = expr(InTemplate) // @S: first statement is potentially converted so cannot be stubbed.
if (in.token == ARROW) {
first match {
- case Typed(tree @ This(name), tpt) if (name == nme.EMPTY.toTypeName) =>
+ case Typed(tree @ This(tpnme.EMPTY), tpt) =>
self = atPos(tree.pos union tpt.pos) { makeSelfDef(nme.WILDCARD, tpt) }
case _ =>
convertToParam(first) match {
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
index 66a3dc356e..25b65f0791 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala
@@ -34,7 +34,7 @@ trait Scanners {
var lastOffset: Offset = 0
/** the name of an identifier */
- var name: Name = null
+ var name: TermName = null
/** the string value of a literal */
var strVal: String = null
@@ -898,14 +898,14 @@ trait Scanners {
/** The highest name index of a keyword token */
private var maxKey = 0
/** An array of all keyword token names */
- private var keyName = new Array[Name](128)
+ private var keyName = new Array[TermName](128)
/** The highest keyword token plus one */
private var tokenCount = 0
/** Enter keyword with given name and token id */
- protected def enterKeyword(n: Name, tokenId: Int) {
+ protected def enterKeyword(n: TermName, tokenId: Int) {
while (tokenId >= keyName.length) {
- val newTokName = new Array[Name](keyName.length * 2)
+ val newTokName = new Array[TermName](keyName.length * 2)
compat.Platform.arraycopy(keyName, 0, newTokName, 0, newTokName.length)
keyName = newTokName
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
index f0d1c536c4..81bb5db286 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/SymbolicXMLBuilder.scala
@@ -22,43 +22,55 @@ import scala.tools.util.StringOps.splitWhere
* @author Burak Emir
* @version 1.0
*/
-abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean)
-{
+abstract class SymbolicXMLBuilder(p: Parsers#Parser, preserveWS: Boolean) {
val global: Global
import global._
- def freshName(prefix: String): Name
var isPattern: Boolean = _
- def _Comment = global.newTypeName("Comment")
- def _Elem = global.newTypeName("Elem")
- def _EntityRef = global.newTypeName("EntityRef")
- def _Group = global.newTypeName("Group")
- def _MetaData = global.newTypeName("MetaData")
- def _NamespaceBinding = global.newTypeName("NamespaceBinding")
- def _NodeBuffer = global.newTypeName("NodeBuffer")
- def _PrefixedAttribute = global.newTypeName("PrefixedAttribute")
- def _ProcInstr = global.newTypeName("ProcInstr")
- def _Text = global.newTypeName("Text")
- def _Unparsed = global.newTypeName("Unparsed")
- def _UnprefixedAttribute = global.newTypeName("UnprefixedAttribute")
-
- def __Elem = global.newTermName("Elem")
- def __Text = global.newTermName("Text")
- def _Null = global.newTermName("Null")
- def _plus = global.newTermName("$amp$plus")
- def _xml = global.newTermName("xml")
-
- final def _buf = global.newTermName("$buf")
- final def _md = global.newTermName("$md")
- final def _scope = global.newTermName("$scope")
- final def _tmpscope = global.newTermName("$tmpscope")
+ trait XMLTypeNames extends LibraryTypeNames {
+ val _Comment: NameType = "Comment"
+ val _Elem: NameType = "Elem"
+ val _EntityRef: NameType = "EntityRef"
+ val _Group: NameType = "Group"
+ val _MetaData: NameType = "MetaData"
+ val _NamespaceBinding: NameType = "NamespaceBinding"
+ val _NodeBuffer: NameType = "NodeBuffer"
+ val _PrefixedAttribute: NameType = "PrefixedAttribute"
+ val _ProcInstr: NameType = "ProcInstr"
+ val _Text: NameType = "Text"
+ val _Unparsed: NameType = "Unparsed"
+ val _UnprefixedAttribute: NameType = "UnprefixedAttribute"
+ }
+
+ trait XMLTermNames extends LibraryTermNames {
+ val _Null: NameType = "Null"
+ val __Elem: NameType = "Elem"
+ val __Text: NameType = "Text"
+ val _buf: NameType = "$buf"
+ val _md: NameType = "$md"
+ val _plus: NameType = "$amp$plus"
+ val _scope: NameType = "$scope"
+ val _tmpscope: NameType = "$tmpscope"
+ val _xml: NameType = "xml"
+ }
+
+ private object xmltypes extends XMLTypeNames {
+ type NameType = TypeName
+ implicit def createNameType(name: String): TypeName = newTypeName(name)
+ }
+ private object xmlterms extends XMLTermNames {
+ type NameType = TermName
+ implicit def createNameType(name: String): TermName = newTermName(name)
+ }
+ import xmltypes._
+ import xmlterms._
// convenience methods
private def LL[A](x: A*): List[List[A]] = List(List(x:_*))
private def const(x: Any) = Literal(Constant(x))
private def wild = Ident(nme.WILDCARD)
- private def wildStar = Ident(nme.WILDCARD_STAR)
+ private def wildStar = Ident(tpnme.WILDCARD_STAR)
private def _scala(name: Name) = Select(Select(Ident(nme.ROOTPKG), nme.scala_), name)
private def _scala_xml(name: Name) = Select(_scala(_xml), name)
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index de5f342a7d..01cfc440c5 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -68,7 +68,7 @@ abstract class TreeBuilder {
val buf = new ListBuffer[(Name, Tree, Position)]
def namePos(tree: Tree, name: Name): Position =
- if (!tree.pos.isRange || name.containsName(nme.DOLLARraw)) tree.pos.focus
+ if (!tree.pos.isRange || name.containsName(nme.raw.DOLLAR)) tree.pos.focus
else {
val start = tree.pos.start
val end = start + name.decode.length
@@ -137,21 +137,27 @@ abstract class TreeBuilder {
def makeAnnotated(t: Tree, annot: Tree): Tree = atPos(annot.pos union t.pos)(Annotated(annot, t))
- def makeSelfDef(name: Name, tpt: Tree): ValDef =
+ def makeSelfDef(name: TermName, tpt: Tree): ValDef =
ValDef(Modifiers(PRIVATE), name, tpt, EmptyTree)
/** If tree is a variable pattern, return Some("its name and type").
* Otherwise return none */
- private def matchVarPattern(tree: Tree): Option[(Name, Tree)] = tree match {
- case Ident(name) => Some((name, TypeTree()))
- case Bind(name, Ident(nme.WILDCARD)) => Some((name, TypeTree()))
- case Typed(Ident(name), tpt) => Some((name, tpt))
- case Bind(name, Typed(Ident(nme.WILDCARD), tpt)) => Some((name, tpt))
- case _ => None
+ private def matchVarPattern(tree: Tree): Option[(Name, Tree)] = {
+ def wildType(t: Tree): Option[Tree] = t match {
+ case Ident(x) if x.toTermName == nme.WILDCARD => Some(TypeTree())
+ case Typed(Ident(x), tpt) if x.toTermName == nme.WILDCARD => Some(tpt)
+ case _ => None
+ }
+ tree match {
+ case Ident(name) => Some((name, TypeTree()))
+ case Bind(name, body) => wildType(body) map (x => (name, x))
+ case Typed(Ident(name), tpt) => Some((name, tpt))
+ case _ => None
+ }
}
/** Create tree representing (unencoded) binary operation expression or pattern. */
- def makeBinop(isExpr: Boolean, left: Tree, op: Name, right: Tree, opPos: Position): Tree = {
+ def makeBinop(isExpr: Boolean, left: Tree, op: TermName, right: Tree, opPos: Position): Tree = {
def mkNamed(args: List[Tree]) =
if (isExpr) args map {
case a @ Assign(id @ Ident(name), rhs) =>
@@ -187,7 +193,7 @@ abstract class TreeBuilder {
else if (parents.tail.isEmpty && stats.isEmpty)
atPos(npos union cpos) { New(parents.head, argss) }
else {
- val x = nme.ANON_CLASS_NAME.toTypeName
+ val x = tpnme.ANON_CLASS_NAME
atPos(npos union cpos) {
Block(
List(
@@ -219,14 +225,14 @@ abstract class TreeBuilder {
else CompoundTypeTree(Template(tps, emptyValDef, Nil))
/** Create tree representing a while loop */
- def makeWhile(lname: Name, cond: Tree, body: Tree): Tree = {
+ def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = {
val continu = atPos(o2p(body.pos.endOrPoint)) { Apply(Ident(lname), Nil) }
val rhs = If(cond, Block(List(body), continu), Literal(()))
LabelDef(lname, Nil, rhs)
}
/** Create tree representing a do-while loop */
- def makeDoWhile(lname: Name, body: Tree, cond: Tree): Tree = {
+ def makeDoWhile(lname: TermName, body: Tree, cond: Tree): Tree = {
val continu = Apply(Ident(lname), Nil)
val rhs = Block(List(body), If(cond, continu, Literal(())))
LabelDef(lname, Nil, rhs)
@@ -264,10 +270,10 @@ abstract class TreeBuilder {
if (valeq) ValEq(pos, pat1, rhs1) else ValFrom(pos, pat1, rhs1)
}
- def makeSyntheticParam(pname: Name) =
+ def makeSyntheticParam(pname: TermName) =
ValDef(Modifiers(PARAM | SYNTHETIC), pname, TypeTree(), EmptyTree)
- def makeSyntheticTypeParam(pname: Name, bounds: Tree) =
+ def makeSyntheticTypeParam(pname: TypeName, bounds: Tree) =
TypeDef(Modifiers(DEFERRED | SYNTHETIC), pname, Nil, bounds)
abstract class Enumerator { def pos: Position }
@@ -323,7 +329,7 @@ abstract class TreeBuilder {
* @param enums The enumerators in the for expression
* @param body The body of the for expression
*/
- private def makeFor(mapName: Name, flatMapName: Name, enums: List[Enumerator], body: Tree): Tree = {
+ private def makeFor(mapName: TermName, flatMapName: TermName, enums: List[Enumerator], body: Tree): Tree = {
/** make a closure pat => body.
* The closure is assigned a transparent position with the point at pos.point and
@@ -345,7 +351,7 @@ abstract class TreeBuilder {
/** Make an application qual.meth(pat => body) positioned at `pos`.
*/
- def makeCombination(pos: Position, meth: Name, qual: Tree, pat: Tree, body: Tree): Tree =
+ def makeCombination(pos: Position, meth: TermName, qual: Tree, pat: Tree, body: Tree): Tree =
Apply(Select(qual, meth) setPos qual.pos, List(makeClosure(pos, pat, body))) setPos pos
/** Optionally, if pattern is a `Bind`, the bound name, otherwise None.
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index 9bbedb6f53..7744a57547 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1771,7 +1771,7 @@ abstract class GenICode extends SubComponent {
val sym = t.symbol
def getLabel(pos: Position, name: Name) =
labels.getOrElseUpdate(sym,
- method.newLabel(sym.pos, unit.fresh.newName(name.toString)) setInfo sym.tpe
+ method.newLabel(sym.pos, unit.freshTermName(name.toString)) setInfo sym.tpe
)
t match {
@@ -2024,7 +2024,7 @@ abstract class GenICode extends SubComponent {
/** Make a fresh local variable. It ensures the 'name' is unique. */
def makeLocal(pos: Position, tpe: Type, name: String): Local = {
- val sym = method.symbol.newVariable(pos, unit.fresh.newName(name))
+ val sym = method.symbol.newVariable(pos, unit.freshTermName(name))
.setInfo(tpe)
.setFlag(Flags.SYNTHETIC)
this.method.addLocal(new Local(sym, toTypeKind(tpe), false))
diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
index f2c3a1c788..4fd59ba0b0 100644
--- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
+++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
@@ -27,6 +27,7 @@ import reflect.generic.{ PickleFormat, PickleBuffer }
*
*/
abstract class GenJVM extends SubComponent {
+ val global: Global
import global._
import icodes._
import icodes.opcodes._
@@ -35,6 +36,7 @@ abstract class GenJVM extends SubComponent {
AnyClass, ObjectClass, ThrowsClass, ThrowableClass, ClassfileAnnotationClass,
SerializableClass, StringClass, ClassClass, FunctionClass,
DeprecatedAttr, SerializableAttr, SerialVersionUIDAttr, VolatileAttr,
+ AndroidParcelableInterface, AndroidCreatorClass,
TransientAttr, CloneableAttr, RemoteAttr,
getPrimitiveCompanion
}
@@ -89,10 +91,10 @@ abstract class GenJVM extends SubComponent {
val PublicStatic = ACC_PUBLIC | ACC_STATIC
val PublicStaticFinal = ACC_PUBLIC | ACC_STATIC | ACC_FINAL
- val StringBuilderClass = definitions.getClass("scala.collection.mutable.StringBuilder").fullName
+ val StringBuilderClassName = definitions.StringBuilderClass.fullName
val BoxesRunTime = "scala.runtime.BoxesRunTime"
- val StringBuilderType = new JObjectType(StringBuilderClass)
+ val StringBuilderType = new JObjectType(StringBuilderClassName)
val toStringType = new JMethodType(JAVA_LANG_STRING, JType.EMPTY_ARRAY)
val arrayCloneType = new JMethodType(JAVA_LANG_OBJECT, JType.EMPTY_ARRAY)
val MethodTypeType = new JObjectType("java.dyn.MethodType")
@@ -109,12 +111,6 @@ abstract class GenJVM extends SubComponent {
lazy val RemoteInterface = definitions.getClass("java.rmi.Remote")
lazy val RemoteException = definitions.getClass("java.rmi.RemoteException").tpe
- lazy val ParcelableInterface =
- try { definitions.getClass("android.os.Parcelable") }
- catch { case _: FatalError => NoSymbol }
- // only evaluated if ParcelableInterface != NoSymbol
- lazy val CreatorClass = definitions.getClass("android.os.Parcelable$Creator")
-
val versionPickle = {
val vp = new PickleBuffer(new Array[Byte](16), -1, 0)
assert(vp.writeIndex == 0)
@@ -176,7 +172,7 @@ abstract class GenJVM extends SubComponent {
currentRun.symData.get(sym) match {
case Some(pickle) if !jclass.getName().endsWith("$") =>
val scalaAttr =
- fjbgContext.JOtherAttribute(jclass, jclass, nme.ScalaSignatureATTR.toString,
+ fjbgContext.JOtherAttribute(jclass, jclass, tpnme.ScalaSignatureATTR.toString,
versionPickle.bytes, versionPickle.writeIndex)
jclass.addAttribute(scalaAttr)
val scalaAnnot = {
@@ -189,7 +185,7 @@ abstract class GenJVM extends SubComponent {
Some(scalaAnnot)
case _ =>
val markerAttr =
- fjbgContext.JOtherAttribute(jclass, jclass, nme.ScalaATTR.toString, new Array[Byte](0), 0)
+ fjbgContext.JOtherAttribute(jclass, jclass, tpnme.ScalaATTR.toString, new Array[Byte](0), 0)
jclass.addAttribute(markerAttr)
None
}
@@ -210,8 +206,8 @@ abstract class GenJVM extends SubComponent {
val name = javaName(c.symbol)
serialVUID = None
isRemoteClass = false
- isParcelableClass = (ParcelableInterface != NoSymbol) &&
- (parents contains ParcelableInterface.tpe)
+ isParcelableClass = (AndroidParcelableInterface != NoSymbol) &&
+ (parents contains AndroidParcelableInterface.tpe)
if (parents.isEmpty)
parents = List(ObjectClass.tpe)
@@ -399,7 +395,7 @@ abstract class GenJVM extends SubComponent {
assert(nattr > 0)
buf.putShort(0, nattr.toShort)
- addAttribute(jmethod, nme.ExceptionsATTR, buf)
+ addAttribute(jmethod, tpnme.ExceptionsATTR, buf)
}
/** Whether an annotation should be emitted as a Java annotation
@@ -527,7 +523,7 @@ abstract class GenJVM extends SubComponent {
}
val buf = ByteBuffer.allocate(2)
buf.putShort(index)
- addAttribute(jmember, nme.SignatureATTR, buf)
+ addAttribute(jmember, tpnme.SignatureATTR, buf)
}
}
}
@@ -535,7 +531,7 @@ abstract class GenJVM extends SubComponent {
def addAnnotations(jmember: JMember, annotations: List[AnnotationInfo]) {
if (annotations.exists(_.atp.typeSymbol == definitions.DeprecatedAttr)) {
val attr = jmember.getContext().JOtherAttribute(
- jmember.getJClass(), jmember, nme.DeprecatedATTR.toString,
+ jmember.getJClass(), jmember, tpnme.DeprecatedATTR.toString,
new Array[Byte](0), 0)
jmember addAttribute attr
}
@@ -545,7 +541,7 @@ abstract class GenJVM extends SubComponent {
val buf: ByteBuffer = ByteBuffer.allocate(2048)
emitJavaAnnotations(jmember.getConstantPool, buf, toEmit)
- addAttribute(jmember, nme.RuntimeAnnotationATTR, buf)
+ addAttribute(jmember, tpnme.RuntimeAnnotationATTR, buf)
}
def addParamAnnotations(jmethod: JMethod, pannotss: List[List[AnnotationInfo]]) {
@@ -559,7 +555,7 @@ abstract class GenJVM extends SubComponent {
for (annots <- annotations)
emitJavaAnnotations(jmethod.getConstantPool, buf, annots)
- addAttribute(jmethod, nme.RuntimeParamAnnotationATTR, buf)
+ addAttribute(jmethod, tpnme.RuntimeParamAnnotationATTR, buf)
}
def addAttribute(jmember: JMember, name: Name, buf: ByteBuffer) {
@@ -813,7 +809,7 @@ abstract class GenJVM extends SubComponent {
val fieldName = "CREATOR"
val fieldSymbol = clasz.symbol.newValue(NoPosition, newTermName(fieldName))
.setFlag(Flags.STATIC | Flags.FINAL)
- .setInfo(CreatorClass.tpe)
+ .setInfo(AndroidCreatorClass.tpe)
val methodSymbol = definitions.getMember(clasz.symbol.companionModule, "CREATOR")
clasz addField new IField(fieldSymbol)
lastBlock emit CALL_METHOD(methodSymbol, Static(false))
@@ -854,7 +850,7 @@ abstract class GenJVM extends SubComponent {
if (isParcelableClass) {
val fieldName = "CREATOR"
- val creatorType = javaType(CreatorClass)
+ val creatorType = javaType(AndroidCreatorClass)
jclass.addNewField(PublicStaticFinal,
fieldName,
creatorType)
@@ -1648,9 +1644,9 @@ abstract class GenJVM extends SubComponent {
jcode.emitARRAYLENGTH()
case StartConcat =>
- jcode emitNEW StringBuilderClass
+ jcode emitNEW StringBuilderClassName
jcode.emitDUP()
- jcode.emitINVOKESPECIAL(StringBuilderClass,
+ jcode.emitINVOKESPECIAL(StringBuilderClassName,
JMethod.INSTANCE_CONSTRUCTOR_NAME,
JMethodType.ARGLESS_VOID_FUNCTION)
@@ -1659,12 +1655,12 @@ abstract class GenJVM extends SubComponent {
case REFERENCE(_) | ARRAY(_) => JAVA_LANG_OBJECT
case _ => javaType(el)
}
- jcode.emitINVOKEVIRTUAL(StringBuilderClass,
+ jcode.emitINVOKEVIRTUAL(StringBuilderClassName,
"append",
new JMethodType(StringBuilderType,
Array(jtype)))
case EndConcat =>
- jcode.emitINVOKEVIRTUAL(StringBuilderClass,
+ jcode.emitINVOKEVIRTUAL(StringBuilderClassName,
"toString",
toStringType)
@@ -1728,7 +1724,7 @@ abstract class GenJVM extends SubComponent {
val attr =
fjbgContext.JOtherAttribute(jclass,
jmethod,
- nme.LocalVariableTableATTR.toString,
+ tpnme.LocalVariableTableATTR.toString,
lvTab.array())
jcode addAttribute attr
}
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 6f8448ad0a..68412098e3 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -271,13 +271,12 @@ abstract class DeadCodeElimination extends SubComponent {
abort("could not find init in: " + method)
}
- lazy val RuntimePackage = definitions.getModule("scala.runtime")
/** Is 'sym' a side-effecting method? TODO: proper analysis. */
private def isSideEffecting(sym: Symbol): Boolean = {
!((sym.isGetter && !sym.isLazy)
|| (sym.isConstructor
&& !(sym.owner == method.symbol.owner && method.symbol.isConstructor) // a call to another constructor
- && sym.owner.owner == RuntimePackage.moduleClass)
+ && sym.owner.owner == definitions.RuntimePackage.moduleClass)
|| (sym.isConstructor && inliner.isClosureClass(sym.owner))
/* || definitions.isBox(sym)
|| definitions.isUnbox(sym)*/)
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index 63c62d8d1e..d6cfdd24b1 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -22,7 +22,7 @@ trait JavaParsers extends JavaScanners {
class JavaUnitParser(val unit: global.CompilationUnit) extends JavaParser {
val in = new JavaUnitScanner(unit)
- def freshName(prefix : String) = unit.fresh.newName(prefix)
+ def freshName(prefix : String) = unit.freshTermName(prefix)
implicit def i2p(offset : Int) : Position = new OffsetPosition(unit.source, offset)
def warning(pos : Int, msg : String) : Unit = unit.warning(pos, msg)
def syntaxError(pos: Int, msg: String) : Unit = unit.error(pos, msg)
@@ -106,10 +106,10 @@ trait JavaParsers extends JavaScanners {
def javaLangDot(name: Name): Tree =
Select(javaDot(nme.lang), name)
- def javaLangObject(): Tree = javaLangDot(nme.Object.toTypeName)
+ def javaLangObject(): Tree = javaLangDot(tpnme.Object)
def arrayOf(tpt: Tree) =
- AppliedTypeTree(scalaDot(nme.Array.toTypeName), List(tpt))
+ AppliedTypeTree(scalaDot(tpnme.Array), List(tpt))
def blankExpr = Ident(nme.WILDCARD)
@@ -192,14 +192,18 @@ trait JavaParsers extends JavaScanners {
}
def acceptClosingAngle() {
- if (in.token == GTGTGTEQ) in.token = GTGTEQ
- else if (in.token == GTGTGT) in.token = GTGT
- else if (in.token == GTGTEQ) in.token = GTEQ
- else if (in.token == GTGT) in.token = GT
- else if (in.token == GTEQ) in.token = ASSIGN
+ val closers: PartialFunction[Int, Int] = {
+ case GTGTGTEQ => GTGTEQ
+ case GTGTGT => GTGT
+ case GTGTEQ => GTEQ
+ case GTGT => GT
+ case GTEQ => ASSIGN
+ }
+ if (closers isDefinedAt in.token) in.token = closers(in.token)
else accept(GT)
}
+ def identForType(): TypeName = ident().toTypeName
def ident(): Name =
if (in.token == IDENTIFIER) {
val name = in.name
@@ -279,7 +283,7 @@ trait JavaParsers extends JavaScanners {
// turns out to be an instance ionner class instead of a static inner class.
def typeSelect(t: Tree, name: Name) = t match {
case Ident(_) | Select(_, _) => Select(t, name)
- case _ => SelectFromTypeTree(t, name)
+ case _ => SelectFromTypeTree(t, name.toTypeName)
}
while (in.token == DOT) {
in.nextToken
@@ -431,7 +435,7 @@ trait JavaParsers extends JavaScanners {
case _ =>
val privateWithin: Name =
if (isPackageAccess && !inInterface) thisPackageName
- else nme.EMPTY.toTypeName
+ else tpnme.EMPTY
return Modifiers(flags, privateWithin) withAnnotations annots
}
@@ -449,16 +453,16 @@ trait JavaParsers extends JavaScanners {
def typeParam(): TypeDef =
atPos(in.currentPos) {
- val name = ident().toTypeName
+ val name = identForType()
val hi =
if (in.token == EXTENDS) {
in.nextToken
bound()
} else {
- scalaDot(nme.Any.toTypeName)
+ scalaDot(tpnme.Any)
}
TypeDef(Modifiers(Flags.JAVA | Flags.DEFERRED | Flags.PARAM), name, List(),
- TypeBoundsTree(scalaDot(nme.Nothing.toTypeName), hi))
+ TypeBoundsTree(scalaDot(tpnme.Nothing), hi))
}
def bound(): Tree =
@@ -487,7 +491,7 @@ trait JavaParsers extends JavaScanners {
if (in.token == DOTDOTDOT) {
in.nextToken
t = atPos(t.pos) {
- AppliedTypeTree(scalaDot(nme.JAVA_REPEATED_PARAM_CLASS_NAME), List(t))
+ AppliedTypeTree(scalaDot(tpnme.JAVA_REPEATED_PARAM_CLASS_NAME), List(t))
}
}
varDecl(in.currentPos, Modifiers(Flags.JAVA | Flags.PARAM), t, ident())
@@ -548,7 +552,7 @@ trait JavaParsers extends JavaScanners {
if (parentToken == AT && in.token == DEFAULT) {
val annot =
atPos(pos) {
- New(Select(scalaDot(newTermName("runtime")), nme.AnnotationDefaultATTR.toTypeName), List(List()))
+ New(Select(scalaDot(newTermName("runtime")), tpnme.AnnotationDefaultATTR), List(List()))
}
mods1 = Modifiers(mods1.flags, mods1.privateWithin, annot :: mods1.annotations, mods1.positions)
skipTo(SEMI)
@@ -613,7 +617,7 @@ trait JavaParsers extends JavaScanners {
buf.toList
}
- def varDecl(pos: Position, mods: Modifiers, tpt: Tree, name: Name): ValDef = {
+ def varDecl(pos: Position, mods: Modifiers, tpt: Tree, name: TermName): ValDef = {
val tpt1 = optArrayBrackets(tpt)
if (in.token == ASSIGN && !mods.isParameter) skipTo(COMMA, SEMI)
val mods1 = if (mods.isFinal) mods &~ Flags.FINAL else mods | Flags.MUTABLE
@@ -714,7 +718,7 @@ trait JavaParsers extends JavaScanners {
def classDecl(mods: Modifiers): List[Tree] = {
accept(CLASS)
val pos = in.currentPos
- val name = ident().toTypeName
+ val name = identForType()
val tparams = typeParams()
val superclass =
if (in.token == EXTENDS) {
@@ -733,7 +737,7 @@ trait JavaParsers extends JavaScanners {
def interfaceDecl(mods: Modifiers): List[Tree] = {
accept(INTERFACE)
val pos = in.currentPos
- val name = ident().toTypeName
+ val name = identForType()
val tparams = typeParams()
val parents =
if (in.token == EXTENDS) {
@@ -795,7 +799,7 @@ trait JavaParsers extends JavaScanners {
accept(AT)
accept(INTERFACE)
val pos = in.currentPos
- val name = ident().toTypeName
+ val name = identForType()
val parents = List(scalaDot(newTypeName("Annotation")),
Select(javaLangDot(newTermName("annotation")), newTypeName("Annotation")),
scalaDot(newTypeName("ClassfileAnnotation")))
@@ -815,7 +819,7 @@ trait JavaParsers extends JavaScanners {
def enumDecl(mods: Modifiers): List[Tree] = {
accept(ENUM)
val pos = in.currentPos
- val name = ident().toTypeName
+ val name = identForType()
def enumType = Ident(name)
val interfaces = interfacesOpt()
accept(LBRACE)
diff --git a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
index fccb1746fe..fd69f15edc 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaScanners.scala
@@ -37,7 +37,7 @@ trait JavaScanners {
var lastPos: Int = 0
/** the name of an identifier or token */
- var name: Name = null
+ var name: TermName = null
/** the base of a number */
var base: Int = 0
@@ -165,7 +165,7 @@ trait JavaScanners {
//Token representation -----------------------------------------------------
/** Convert name to token */
- def name2token(name: Name): Int =
+ def name2token(name: TermName): Int =
if (name.start <= maxKey) key(name.start) else IDENTIFIER
/** Returns the string representation of given token. */
diff --git a/src/compiler/scala/tools/nsc/matching/Matrix.scala b/src/compiler/scala/tools/nsc/matching/Matrix.scala
index d914f1c17f..a1f260519b 100644
--- a/src/compiler/scala/tools/nsc/matching/Matrix.scala
+++ b/src/compiler/scala/tools/nsc/matching/Matrix.scala
@@ -206,8 +206,6 @@ trait Matrix extends MatrixAdditions {
override def toString() = "%s: %s = %s".format(lhs, lhs.info, rhs)
}
- def newName(s: String) = cunit.fresh.newName(s)
-
/** Sets the rhs to EmptyTree, which makes the valDef ignored in Scrutinee.
*/
def specialVar(lhs: Symbol, checked: Boolean) =
@@ -223,7 +221,7 @@ trait Matrix extends MatrixAdditions {
label: String = "temp"): PatternVar =
{
val tpe = ifNull(_tpe, root.tpe)
- val name = newName(label)
+ val name = cunit.freshTermName(label)
val sym = newVar(root.pos, tpe, flags(checked), name)
tracing("copy", new PatternVar(sym, root, checked))
@@ -243,9 +241,9 @@ trait Matrix extends MatrixAdditions {
pos: Position,
tpe: Type,
flags: List[Long] = Nil,
- name: Name = null): Symbol =
+ name: TermName = null): Symbol =
{
- val n: Name = if (name == null) newName("temp") else name
+ val n = if (name == null) cunit.freshTermName("temp") else name
// careful: pos has special meaning
recordSyntheticSym(owner.newVariable(pos, n) setInfo tpe setFlag (SYNTHETIC.toLong /: flags)(_|_))
}
diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
index 4b717f209c..169518b9ab 100644
--- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
+++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala
@@ -544,7 +544,7 @@ trait ParallelMatching extends ast.TreeDSL
}
lazy val label =
- owner.newLabel(scrut.pos, newName("failCont%")) setInfo MethodType(Nil, labelBody.tpe)
+ owner.newLabel(scrut.pos, cunit.freshTermName("failCont%")) setInfo MethodType(Nil, labelBody.tpe)
lazy val cond =
handleOuter(rhs MEMBER_== scrut.id )
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index db757a66f5..789f803965 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -28,7 +28,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
RootClass.sourceModule = rp
rp
}
- lazy val RootClass: ModuleClassSymbol = NoSymbol.newModuleClass(NoPosition, nme.ROOT.toTypeName)
+ lazy val RootClass: ModuleClassSymbol = NoSymbol.newModuleClass(NoPosition, tpnme.ROOT)
.setFlag(FINAL | MODULE | PACKAGE | JAVA).setInfo(rootLoader)
lazy val EmptyPackage = RootClass.newPackage(NoPosition, nme.EMPTY_PACKAGE_NAME).setFlag(FINAL)
@@ -66,24 +66,22 @@ trait Definitions extends reflect.generic.StandardDefinitions {
private def stringtype = StringClass.typeConstructor
// top types
- lazy val AnyClass = newClass(ScalaPackageClass, nme.Any, Nil) setFlag (ABSTRACT)
- lazy val AnyValClass = newClass(ScalaPackageClass, nme.AnyVal, anyparam) setFlag (ABSTRACT | SEALED)
- lazy val AnyRefClass = newAlias(ScalaPackageClass, nme.AnyRef, ObjectClass.typeConstructor)
+ lazy val AnyClass = newClass(ScalaPackageClass, tpnme.Any, Nil) setFlag (ABSTRACT)
+ lazy val AnyValClass = newClass(ScalaPackageClass, tpnme.AnyVal, anyparam) setFlag (ABSTRACT | SEALED)
+ lazy val AnyRefClass = newAlias(ScalaPackageClass, tpnme.AnyRef, ObjectClass.typeConstructor)
lazy val ObjectClass = getClass(sn.Object)
// bottom types
- lazy val NullClass = newClass(ScalaPackageClass, nme.Null, anyrefparam) setFlag (ABSTRACT | TRAIT | FINAL)
- lazy val NothingClass = newClass(ScalaPackageClass, nme.Nothing, anyparam) setFlag (ABSTRACT | TRAIT | FINAL)
+ lazy val NullClass = newClass(ScalaPackageClass, tpnme.Null, anyrefparam) setFlag (ABSTRACT | TRAIT | FINAL)
+ lazy val NothingClass = newClass(ScalaPackageClass, tpnme.Nothing, anyparam) setFlag (ABSTRACT | TRAIT | FINAL)
lazy val RuntimeNothingClass = getClass(ClassfileConstants.SCALA_NOTHING)
lazy val RuntimeNullClass = getClass(ClassfileConstants.SCALA_NULL)
lazy val AnyValCompanionClass = getClass("scala.runtime.AnyValCompanion").setFlag(SEALED | ABSTRACT | TRAIT)
// the scala value classes
- lazy val UnitClass =
- newClass(ScalaPackageClass, nme.Unit, anyvalparam).setFlag(ABSTRACT | FINAL)
-
import ClassfileConstants._
+ lazy val UnitClass = newClass(ScalaPackageClass, tpnme.Unit, anyvalparam).setFlag(ABSTRACT | FINAL)
lazy val ByteClass = newValueClass(nme.Byte, BYTE_TAG, 2)
lazy val ShortClass = newValueClass(nme.Short, SHORT_TAG, 4)
lazy val CharClass = newValueClass(nme.Char, CHAR_TAG, 3)
@@ -112,7 +110,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val IndexOutOfBoundsExceptionClass = getClass(sn.IOOBException)
lazy val InvocationTargetExceptionClass = getClass(sn.InvTargetException)
lazy val MatchErrorClass = getClass("scala.MatchError")
- lazy val NonLocalReturnControlClass = getClass(sn.NLRControl)
+ lazy val NonLocalReturnControlClass = getClass("scala.runtime.NonLocalReturnControl")
lazy val NullPointerExceptionClass = getClass(sn.NPException)
lazy val ThrowableClass = getClass(sn.Throwable)
lazy val UninitializedErrorClass = getClass("scala.UninitializedFieldError")
@@ -169,28 +167,29 @@ trait Definitions extends reflect.generic.StandardDefinitions {
def scalaRuntimeSameElements = getMember(ScalaRunTimeModule, nme.sameElements)
// classes with special meanings
- lazy val NotNullClass = getClass("scala.NotNull")
- lazy val DelayedInitClass = getClass("scala.DelayedInit")
+ lazy val NotNullClass = getClass("scala.NotNull")
+ lazy val DelayedInitClass = getClass("scala.DelayedInit")
def delayedInitMethod = getMember(DelayedInitClass, nme.delayedInit)
// a dummy value that communicates that a delayedInit call is compiler-generated
// from phase UnCurry to phase Constructors
def delayedInitArgVal = EmptyPackageClass.newValue(NoPosition, nme.delayedInitArg)
.setInfo(UnitClass.tpe)
+
lazy val TypeConstraintClass = getClass("scala.TypeConstraint")
- lazy val SingletonClass = newClass(ScalaPackageClass, nme.Singleton, anyparam) setFlag (ABSTRACT | TRAIT | FINAL)
+ lazy val SingletonClass = newClass(ScalaPackageClass, tpnme.Singleton, anyparam) setFlag (ABSTRACT | TRAIT | FINAL)
lazy val SerializableClass = getClass("scala.Serializable")
lazy val JavaSerializableClass = getClass(sn.JavaSerializable)
lazy val ComparableClass = getClass("java.lang.Comparable")
lazy val RepeatedParamClass = newCovariantPolyClass(
ScalaPackageClass,
- nme.REPEATED_PARAM_CLASS_NAME,
+ tpnme.REPEATED_PARAM_CLASS_NAME,
tparam => seqType(tparam.typeConstructor)
)
lazy val JavaRepeatedParamClass = newCovariantPolyClass(
ScalaPackageClass,
- nme.JAVA_REPEATED_PARAM_CLASS_NAME,
+ tpnme.JAVA_REPEATED_PARAM_CLASS_NAME,
tparam => arrayType(tparam.typeConstructor)
)
@@ -214,21 +213,22 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val ByNameParamClass = newCovariantPolyClass(
ScalaPackageClass,
- nme.BYNAME_PARAM_CLASS_NAME,
+ tpnme.BYNAME_PARAM_CLASS_NAME,
tparam => AnyClass.typeConstructor
)
lazy val EqualsPatternClass = {
- val clazz = newClass(ScalaPackageClass, nme.EQUALS_PATTERN_NAME, Nil)
+ val clazz = newClass(ScalaPackageClass, tpnme.EQUALS_PATTERN_NAME, Nil)
clazz setInfo PolyType(List(newTypeParam(clazz, 0)), ClassInfoType(anyparam, new Scope, clazz))
}
// collections classes
- lazy val ConsClass = getClass("scala.collection.immutable.$colon$colon")
- lazy val IterableClass = getClass("scala.collection.Iterable")
- lazy val IteratorClass = getClass("scala.collection.Iterator")
- lazy val ListClass = getClass("scala.collection.immutable.List")
- lazy val SeqClass = getClass("scala.collection.Seq")
- lazy val TraversableClass = getClass("scala.collection.Traversable")
+ lazy val ConsClass = getClass("scala.collection.immutable.$colon$colon")
+ lazy val IterableClass = getClass("scala.collection.Iterable")
+ lazy val IteratorClass = getClass("scala.collection.Iterator")
+ lazy val ListClass = getClass("scala.collection.immutable.List")
+ lazy val SeqClass = getClass("scala.collection.Seq")
+ lazy val StringBuilderClass = getClass("scala.collection.mutable.StringBuilder")
+ lazy val TraversableClass = getClass("scala.collection.Traversable")
lazy val ListModule = getModule("scala.collection.immutable.List")
lazy val NilModule = getModule("scala.collection.immutable.Nil")
@@ -287,10 +287,10 @@ trait Definitions extends reflect.generic.StandardDefinitions {
def longType = typeRef(LongClass.typeConstructor.prefix, LongClass, List())
// Product, Tuple, Function
- private def mkArityArray(name: String, arity: Int, countFrom: Int = 1) = {
- val list = (countFrom to arity).toList map (i => getClass(("scala." + name + i): Name))
+ private def mkArityArray(name: String, arity: Int, countFrom: Int = 1): Array[Symbol] = {
+ val list = countFrom to arity map (i => getClass("scala." + name + i))
if (countFrom == 0) list.toArray
- else (NoSymbol :: list).toArray
+ else (NoSymbol +: list).toArray
}
val MaxTupleArity, MaxProductArity, MaxFunctionArity = 22
@@ -490,33 +490,48 @@ trait Definitions extends reflect.generic.StandardDefinitions {
lazy val VolatileAttr: Symbol = getClass("scala.volatile")
lazy val AnnotationDefaultAttr: Symbol = {
- val attr = newClass(RuntimePackageClass, nme.AnnotationDefaultATTR, List(AnnotationClass.typeConstructor))
+ val attr = newClass(RuntimePackageClass, tpnme.AnnotationDefaultATTR, List(AnnotationClass.typeConstructor))
// This attribute needs a constructor so that modifiers in parsed Java code make sense
attr.info.decls enter (attr newConstructor NoPosition setInfo MethodType(Nil, attr.tpe))
attr
}
+ // Android. I moved it into definitions because it threw an expensive
+ // exception on every repl line.
+ lazy val AndroidParcelableInterface =
+ try getClass("android.os.Parcelable")
+ catch { case _: FatalError => NoSymbol }
+ lazy val AndroidCreatorClass =
+ if (AndroidParcelableInterface == NoSymbol) NoSymbol
+ else getClass("android.os.Parcelable$Creator")
+
def getModule(fullname: Name): Symbol =
- getModuleOrClass(fullname, true)
+ getModuleOrClass(fullname.toTermName)
def getClass(fullname: Name): Symbol = {
- var result = getModuleOrClass(fullname, false)
+ var result = getModuleOrClass(fullname.toTypeName)
while (result.isAliasType) result = result.info.typeSymbol
result
}
def getMember(owner: Symbol, name: Name): Symbol = {
- if (owner == NoSymbol) return NoSymbol
- val result = owner.info.nonPrivateMember(name)
- if (result == NoSymbol) {
- throw new FatalError(owner.toString() + " does not have a member " + name)
+ if (owner == NoSymbol) NoSymbol
+ else owner.info.nonPrivateMember(name) match {
+ case NoSymbol => throw new FatalError(owner + " does not have a member " + name)
+ case result => result
}
- result
}
- private def getModuleOrClass(fullname: Name, module: Boolean): Symbol = {
- if (fullname == nme.NOSYMBOL) return NoSymbol
- var sym:Symbol = RootClass
+ /** If you're looking for a class, pass a type name.
+ * If a module, a term name.
+ */
+ private def getModuleOrClass(path: Name): Symbol = {
+ val module = path.isTermName
+ val fullname = path.toTermName
+ if (fullname == nme.NO_NAME)
+ return NoSymbol
+
+ var sym: Symbol = RootClass
var i = 0
var j = fullname.pos('.', i)
while (j < fullname.length) {
@@ -532,20 +547,21 @@ trait Definitions extends reflect.generic.StandardDefinitions {
{ log(sym.info); log(sym.info.members) }//debug
throw new MissingRequirementError((if (module) "object " else "class ") + fullname)
}
+
result
}
- private def newClass(owner: Symbol, name: Name, parents: List[Type]): Symbol = {
- val clazz = owner.newClass(NoPosition, name.toTypeName)
+ private def newClass(owner: Symbol, name: TypeName, parents: List[Type]): Symbol = {
+ val clazz = owner.newClass(NoPosition, name)
clazz.setInfo(ClassInfoType(parents, new Scope, clazz))
owner.info.decls.enter(clazz)
clazz
}
- private def newCovariantPolyClass(owner: Symbol, name: Name, parent: Symbol => Type): Symbol = {
- val clazz = newClass(owner, name, List())
+ private def newCovariantPolyClass(owner: Symbol, name: TypeName, parent: Symbol => Type): Symbol = {
+ val clazz = newClass(owner, name, List())
val tparam = newTypeParam(clazz, 0) setFlag COVARIANT
- val p = parent(tparam)
+ val p = parent(tparam)
/* p.typeSymbol.initialize
println(p.typeSymbol + " flags: " + Flags.flagsToString(p.typeSymbol.flags))
val parents = /*if (p.typeSymbol.isTrait)
@@ -558,41 +574,41 @@ trait Definitions extends reflect.generic.StandardDefinitions {
ClassInfoType(List(AnyRefClass.tpe, p), new Scope, clazz)))
}
- private def newAlias(owner: Symbol, name: Name, alias: Type): Symbol = {
- val tpsym = owner.newAliasType(NoPosition, name.toTypeName)
+ private def newAlias(owner: Symbol, name: TypeName, alias: Type): Symbol = {
+ val tpsym = owner.newAliasType(NoPosition, name)
tpsym.setInfo(alias)
owner.info.decls.enter(tpsym)
tpsym
}
- private def newMethod(owner: Symbol, name: Name): Symbol = {
+ private def newMethod(owner: Symbol, name: TermName): Symbol = {
val msym = owner.newMethod(NoPosition, name.encode)
owner.info.decls.enter(msym)
msym
}
- private def newMethod(owner: Symbol, name: Name, formals: List[Type], restpe: Type): Symbol = {
+ private def newMethod(owner: Symbol, name: TermName, formals: List[Type], restpe: Type): Symbol = {
val msym = newMethod(owner, name)
val params = msym.newSyntheticValueParams(formals)
msym.setInfo(MethodType(params, restpe))
}
/** tcon receives the type parameter symbol as argument */
- private def newPolyMethod(owner: Symbol, name: Name, tcon: Symbol => Type): Symbol =
+ private def newPolyMethod(owner: Symbol, name: TermName, tcon: Symbol => Type): Symbol =
newPolyMethodCon(owner, name, tparam => msym => tcon(tparam))
/** tcon receives the type parameter symbol and the method symbol as arguments */
- private def newPolyMethodCon(owner: Symbol, name: Name, tcon: Symbol => Symbol => Type): Symbol = {
+ private def newPolyMethodCon(owner: Symbol, name: TermName, tcon: Symbol => Symbol => Type): Symbol = {
val msym = newMethod(owner, name)
val tparam = newTypeParam(msym, 0)
msym.setInfo(PolyType(List(tparam), tcon(tparam)(msym)))
}
- private def newParameterlessMethod(owner: Symbol, name: Name, restpe: Type) =
+ private def newParameterlessMethod(owner: Symbol, name: TermName, restpe: Type) =
newMethod(owner, name).setInfo(PolyType(List(),restpe))
private def newTypeParam(owner: Symbol, index: Int): Symbol =
- owner.newTypeParameter(NoPosition, "T" + index)
+ owner.newTypeParameter(NoPosition, newTypeName("T" + index))
.setInfo(TypeBounds(NothingClass.typeConstructor, AnyClass.typeConstructor))
val boxedClass = new HashMap[Symbol, Symbol]
@@ -635,10 +651,11 @@ trait Definitions extends reflect.generic.StandardDefinitions {
primitiveCompanions += module
}
- private[symtab] def newValueClass(name: Name, tag: Char, weight: Int): Symbol = {
- val boxedName = sn.Boxed(name)
+ private[symtab] def newValueClass(name: TermName, tag: Char, weight: Int): Symbol = {
+ val tpName = name.toTypeName
+ val boxedName = sn.Boxed(tpName).toTermName
- val clazz = newClass(ScalaPackageClass, name, anyvalparam) setFlag (ABSTRACT | FINAL)
+ val clazz = newClass(ScalaPackageClass, tpName, anyvalparam) setFlag (ABSTRACT | FINAL)
boxedClass(clazz) = getClass(boxedName)
boxedModule(clazz) = getModule(boxedName)
refClass(clazz) = getClass("scala.runtime." + name + "Ref")
@@ -646,17 +663,15 @@ trait Definitions extends reflect.generic.StandardDefinitions {
abbrvTag(clazz) = tag
if (weight > 0) numericWeight(clazz) = weight
- val module = ScalaPackageClass.newModule(NoPosition, name)
+ val module = ScalaPackageClass.newModule(NoPosition, name.toTermName)
ScalaPackageClass.info.decls.enter(module)
val mclass = module.moduleClass
mclass.setInfo(ClassInfoType(List(AnyRefClass.tpe, AnyValCompanionClass.tpe), new Scope, mclass))
module.setInfo(mclass.tpe)
primitiveCompanions += module
- val box = newMethod(mclass, nme.box, List(clazz.typeConstructor), boxedClass(clazz).tpe)
- boxMethod(clazz) = box
- val unbox = newMethod(mclass, nme.unbox, List(ObjectClass.typeConstructor), clazz.typeConstructor)
- unboxMethod(clazz) = unbox
+ boxMethod(clazz) = newMethod(mclass, nme.box, List(clazz.typeConstructor), boxedClass(clazz).tpe)
+ unboxMethod(clazz) = newMethod(mclass, nme.unbox, List(ObjectClass.typeConstructor), clazz.typeConstructor)
clazz
}
@@ -728,11 +743,11 @@ trait Definitions extends reflect.generic.StandardDefinitions {
List(ByteClass, ShortClass, CharClass, IntClass, LongClass) foreach (x => initValueClass(x, true))
List(FloatClass, DoubleClass) foreach (x => initValueClass(x, false))
- def addModuleMethod(clazz: Symbol, name: Name, value: Any) = {
+ def addModuleMethod(clazz: Symbol, name: TermName, value: Any) = {
val owner = clazz.linkedClassOfClass
newParameterlessMethod(owner, name, ConstantType(Constant(value)))
}
- def addDeprecatedModuleMethod(clazz: Symbol, name: Name, value: Any, msg: String) = {
+ def addDeprecatedModuleMethod(clazz: Symbol, name: TermName, value: Any, msg: String) = {
val m = addModuleMethod(clazz, name, value)
val arg = Literal(Constant(msg))
m.addAnnotation(AnnotationInfo(DeprecatedAttr.tpe, List(arg), List()))
diff --git a/src/compiler/scala/tools/nsc/symtab/NameManglers.scala b/src/compiler/scala/tools/nsc/symtab/NameManglers.scala
index 525fcced84..d9a1da7731 100644
--- a/src/compiler/scala/tools/nsc/symtab/NameManglers.scala
+++ b/src/compiler/scala/tools/nsc/symtab/NameManglers.scala
@@ -20,7 +20,6 @@ trait NameManglers {
val IMPL_CLASS_SUFFIX = "$class"
val LOCALDUMMY_PREFIX = "<local " // owner of local blocks
- val LOCAL_SUFFIX = newTermName(LOCAL_SUFFIX_STRING)
val PROTECTED_PREFIX = "protected$"
val PROTECTED_SET_PREFIX = PROTECTED_PREFIX + "set"
val SELECTOR_DUMMY = "<unapply-selector>"
@@ -32,15 +31,15 @@ trait NameManglers {
def isExceptionResultName(name: Name) = name startsWith EXCEPTION_RESULT_PREFIX
def isImplClassName(name: Name) = name endsWith IMPL_CLASS_SUFFIX
def isLocalDummyName(name: Name) = name startsWith LOCALDUMMY_PREFIX
- def isLocalName(name: Name) = name endsWith LOCAL_SUFFIX
+ def isLocalName(name: Name) = name endsWith LOCAL_SUFFIX_STRING
def isLoopHeaderLabel(name: Name) = (name startsWith WHILE_PREFIX) || (name startsWith DO_WHILE_PREFIX)
def isProtectedAccessorName(name: Name) = name startsWith PROTECTED_PREFIX
def isSetterName(name: Name) = name endsWith SETTER_SUFFIX
def isTraitSetterName(name: Name) = isSetterName(name) && (name containsName TRAIT_SETTER_SEPARATOR_STRING)
def isOpAssignmentName(name: Name) = name match {
- case NEraw | LEraw | GEraw | EMPTY => false
- case _ =>
+ case raw.NE | raw.LE | raw.GE | EMPTY => false
+ case _ =>
name.endChar == '=' && name.startChar != '=' && isOperatorPart(name.startChar)
}
@@ -75,16 +74,16 @@ trait NameManglers {
val name1 = name.subName(0, name.length - 3)
val idxC = name1.lastPos('c')
val idxM = name1.lastPos('m', idxC)
- (name1.subName(0, idxM - 1).toString,
+ (name1.subName(0, idxM - 1),
name1.subName(idxC + 1, name1.length).toString,
name1.subName(idxM + 1, idxC).toString)
} else
(name, "", "")
def getterName(name: Name): Name = if (isLocalName(name)) localToGetter(name) else name
- def getterToLocal(name: Name): Name = name append LOCAL_SUFFIX
+ def getterToLocal(name: Name): Name = name append LOCAL_SUFFIX_STRING
def getterToSetter(name: Name): Name = name append SETTER_SUFFIX
- def localToGetter(name: Name): Name = name stripEnd LOCAL_SUFFIX
+ def localToGetter(name: Name): Name = name stripEnd LOCAL_SUFFIX_STRING
def setterToGetter(name: Name): Name = {
val p = name.pos(TRAIT_SETTER_SEPARATOR_STRING)
diff --git a/src/compiler/scala/tools/nsc/symtab/Names.scala b/src/compiler/scala/tools/nsc/symtab/Names.scala
index 0c473c33ef..04cd8a8d84 100644
--- a/src/compiler/scala/tools/nsc/symtab/Names.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Names.scala
@@ -100,7 +100,7 @@ trait Names extends reflect.generic.Names {
/** Create a term name from the characters in cs[offset..offset+len-1].
*/
- def newTermName(cs: Array[Char], offset: Int, len: Int): Name = {
+ def newTermName(cs: Array[Char], offset: Int, len: Int): TermName = {
val h = hashValue(cs, offset, len) & HASH_MASK
var n = termHashtable(h)
while ((n ne null) && (n.length != len || !equals(n.start, cs, offset, len)))
@@ -114,41 +114,51 @@ trait Names extends reflect.generic.Names {
/** create a term name from string
*/
- def newTermName(s: String): Name =
+ def newTermName(s: String): TermName =
newTermName(s.toCharArray(), 0, s.length())
/** Create a term name from the UTF8 encoded bytes in bs[offset..offset+len-1].
*/
- def newTermName(bs: Array[Byte], offset: Int, len: Int): Name =
+ def newTermName(bs: Array[Byte], offset: Int, len: Int): TermName =
newTermName(Codec toUTF8 bs.slice(offset, offset + len) mkString)
/** Create a type name from the characters in cs[offset..offset+len-1].
*/
- def newTypeName(cs: Array[Char], offset: Int, len: Int): Name =
+ def newTypeName(cs: Array[Char], offset: Int, len: Int): TypeName =
newTermName(cs, offset, len).toTypeName
/** Create a type name from string
*/
- def newTypeName(s: String): Name =
+ def newTypeName(s: String): TypeName =
newTermName(s).toTypeName
/** Create a type name from the UTF8 encoded bytes in bs[offset..offset+len-1].
*/
- def newTypeName(bs: Array[Byte], offset: Int, len: Int): Name =
+ def newTypeName(bs: Array[Byte], offset: Int, len: Int): TypeName =
newTermName(bs, offset, len).toTypeName
- def mkTermName(name: Name) = name.toTermName
- def mkTypeName(name: Name) = name.toTypeName
+ def mkTermName(name: Name): TermName = name.toTermName
+ def mkTypeName(name: Name): TypeName = name.toTypeName
+ def isTermName(name: Name): Boolean = name.isTermName
+ def isTypeName(name: Name): Boolean = name.isTypeName
def nameChars: Array[Char] = chrs
-
- implicit def view(s: String): Name = newTermName(s)
+ @deprecated("") def view(s: String): TermName = newTermName(s)
+
+ override def onNameTranslate(name: Name): Unit = {
+ if (nameDebug) {
+ Console println "Translating %s '%s' to %s.".format(
+ if (isTypeName(name)) "type" else "term",
+ name,
+ if (isTypeName(name)) "term" else "type"
+ )
+ }
+ }
// Classes ----------------------------------------------------------------------
/** The name class. */
abstract class Name(index: Int, len: Int) extends Function1[Int, Char] {
-
/** Index into name table */
def start: Int = index
@@ -164,8 +174,8 @@ trait Names extends reflect.generic.Names {
def isTermName: Boolean
def isTypeName: Boolean
- def toTermName: Name
- def toTypeName: Name
+ def toTermName: TermName
+ def toTypeName: TypeName
/** Copy bytes of this name to buffer cs, starting at position `offset`.
*/
@@ -183,6 +193,7 @@ trait Names extends reflect.generic.Names {
/** return the string representation of this name
*/
final override def toString(): String = new String(chrs, index, len)
+ def debugString() = NameTransformer.decode(toString) + (if (isTypeName) "!" else "")
/** Write to UTF8 representation of this name to given character array.
* Start copying to index `to'. Return index of next free byte in array.
@@ -199,6 +210,29 @@ trait Names extends reflect.generic.Names {
*/
final override def hashCode(): Int = index
+ // Presently disabled.
+ // override def equals(other: Any) = paranoidEquals(other)
+ private def paranoidEquals(other: Any): Boolean = {
+ val cmp = this eq other.asInstanceOf[AnyRef]
+ if (cmp || !nameDebug)
+ return cmp
+
+ other match {
+ case x: String =>
+ Console.println("Compared " + debugString + " and String '" + x + "'")
+ case x: Name =>
+ if (this.isTermName != x.isTermName) {
+ val panic = this.toTermName == x.toTermName
+ Console.println("Compared '%s' and '%s', one term, one type.%s".format(this, x,
+ if (panic) " And they contain the same name string!"
+ else ""
+ ))
+ }
+ case _ =>
+ }
+ false
+ }
+
/** return the i'th Char of this name
*/
final def apply(i: Int): Char = chrs(index + i)
@@ -250,7 +284,7 @@ trait Names extends reflect.generic.Names {
*/
final def lastPos(c: Char): Int = lastPos(c, len - 1)
- final def lastPos(s: String): Int = lastPos(s, len - s.length())
+ final def lastPos(s: String): Int = lastPos(s, len - s.length)
/** return the index of the last occurrence of char c in this
* name from start, -1 if not found.
@@ -313,6 +347,7 @@ trait Names extends reflect.generic.Names {
i > suffix.length
}
+ final def containsName(subname: String): Boolean = containsName(newTermName(subname))
final def containsName(subname: Name): Boolean = {
var start = 0
val last = len - subname.length
@@ -323,15 +358,16 @@ trait Names extends reflect.generic.Names {
/** Some thoroughly self-explanatory convenience functions. They
* assume that what they're being asked to do is known to be valid.
*/
- final def startChar: Char = apply(0)
- final def endChar: Char = apply(len - 1)
- final def startsWith(char: Char): Boolean = len > 0 && startChar == char
- final def endsWith(char: Char): Boolean = len > 0 && endChar == char
- final def stripStart(prefix: Name): Name = subName(prefix.length, len)
- final def stripEnd(suffix: Name): Name = subName(0, len - suffix.length)
- final def append(suffix: Name): Name =
- if (isTermName) newTermName(this.toString + suffix)
- else newTypeName(this.toString + suffix)
+ final def startChar: Char = apply(0)
+ final def endChar: Char = apply(len - 1)
+ final def startsWith(char: Char): Boolean = len > 0 && startChar == char
+ final def startsWith(name: String): Boolean = startsWith(newTermName(name))
+ final def endsWith(char: Char): Boolean = len > 0 && endChar == char
+ final def endsWith(name: String): Boolean = endsWith(newTermName(name))
+ final def stripStart(prefix: Name): Name = subName(prefix.length, len)
+ final def stripStart(prefix: String): Name = subName(prefix.length, len)
+ final def stripEnd(suffix: Name): Name = subName(0, len - suffix.length)
+ final def stripEnd(suffix: String): Name = subName(0, len - suffix.length)
/** Return the subname with characters from start to end-1.
*/
@@ -361,6 +397,13 @@ trait Names extends reflect.generic.Names {
else newTermName(res)
}
+ def append(suffix: String): Name = {
+ val chars = this + suffix
+ if (isTypeName) newTypeName(chars)
+ else newTermName(chars)
+ }
+ def append(suffix: Name): Name = append(suffix.toString)
+
/** Replace $op_name by corresponding operator symbol.
*/
def decode: String = (
@@ -370,13 +413,13 @@ trait Names extends reflect.generic.Names {
def isOperatorName: Boolean = decode != toString
}
- private class TermName(index: Int, len: Int, hash: Int) extends Name(index, len) {
+ final class TermName(index: Int, len: Int, hash: Int) extends Name(index, len) {
next = termHashtable(hash)
termHashtable(hash) = this
def isTermName: Boolean = true
def isTypeName: Boolean = false
- def toTermName: Name = this
- def toTypeName = {
+ def toTermName: TermName = this
+ def toTypeName: TypeName = {
val h = hashValue(chrs, index, len) & HASH_MASK
var n = typeHashtable(h)
while ((n ne null) && n.start != index)
@@ -385,16 +428,16 @@ trait Names extends reflect.generic.Names {
n = new TypeName(index, len, h);
n
}
- def subName(from: Int, to: Int): Name =
+ def subName(from: Int, to: Int): TermName =
newTermName(chrs, start + from, to - from)
}
- private class TypeName(index: Int, len: Int, hash: Int) extends Name(index, len) {
+ final class TypeName(index: Int, len: Int, hash: Int) extends Name(index, len) {
next = typeHashtable(hash)
typeHashtable(hash) = this
def isTermName: Boolean = false
def isTypeName: Boolean = true
- def toTermName: Name = {
+ def toTermName: TermName = {
val h = hashValue(chrs, index, len) & HASH_MASK
var n = termHashtable(h)
while ((n ne null) && n.start != index)
@@ -403,8 +446,8 @@ trait Names extends reflect.generic.Names {
n = new TermName(index, len, h);
n
}
- def toTypeName: Name = this
- def subName(from: Int, to: Int): Name =
+ def toTypeName: TypeName = this
+ def subName(from: Int, to: Int): TypeName =
newTypeName(chrs, start + from, to - from)
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index e3a23b2b43..54c3ff9310 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -6,12 +6,271 @@
package scala.tools.nsc
package symtab
-import scala.collection.{ mutable, immutable }
+import scala.collection.immutable
trait StdNames extends reflect.generic.StdNames with NameManglers {
self: SymbolTable =>
- object nme extends StandardNames with NameMangling {
+ trait CompilerCommonNames extends LibraryCommonNames {
+ final val Any: NameType = "Any"
+ final val AnyRef: NameType = "AnyRef"
+ final val AnyVal: NameType = "AnyVal"
+ final val Array: NameType = "Array"
+ final val Boolean: NameType = "Boolean"
+ final val Byte: NameType = "Byte"
+ final val Char: NameType = "Char"
+ final val Double: NameType = "Double"
+ final val Float: NameType = "Float"
+ final val Function: NameType = "Function"
+ final val Int: NameType = "Int"
+ final val List: NameType = "List"
+ final val Long: NameType = "Long"
+ final val Nil: NameType = "Nil"
+ final val Object: NameType = "Object"
+ final val PartialFunction: NameType = "PartialFunction"
+ final val Predef: NameType = "Predef"
+ final val Product: NameType = "Product"
+ final val ScalaObject: NameType = "ScalaObject"
+ final val ScalaRunTime: NameType = "ScalaRunTime"
+ final val Seq: NameType = "Seq"
+ final val Short: NameType = "Short"
+ final val Some: NameType = "Some"
+ final val String: NameType = "String"
+ final val Symbol: NameType = "Symbol"
+ final val Unit: NameType = "Unit"
+
+ final val ERROR: NameType = "<error>"
+ final val NO_NAME: NameType = "<none>" // formerly NOSYMBOL
+ final val STAR: NameType = "*"
+ final val WILDCARD: NameType = "_"
+ }
+
+ trait CompilerTermNames extends CompilerCommonNames {
+ // Scala keywords
+ final val ABSTRACTkw: NameType = "abstract"
+ final val CASEkw: NameType = "case"
+ final val CLASSkw: NameType = "class"
+ final val CATCHkw: NameType = "catch"
+ final val DEFkw: NameType = "def"
+ final val DOkw: NameType = "do"
+ final val ELSEkw: NameType = "else"
+ final val EXTENDSkw: NameType = "extends"
+ final val FALSEkw: NameType = "false"
+ final val FINALkw: NameType = "final"
+ final val FINALLYkw: NameType = "finally"
+ final val FORkw: NameType = "for"
+ final val FORSOMEkw: NameType = "forSome"
+ final val IFkw: NameType = "if"
+ final val IMPLICITkw: NameType = "implicit"
+ final val IMPORTkw: NameType = "import"
+ final val LAZYkw: NameType = "lazy"
+ final val MATCHkw: NameType = "match"
+ final val NEWkw: NameType = "new"
+ final val NULLkw: NameType = "null"
+ final val OBJECTkw: NameType = "object"
+ final val OVERRIDEkw: NameType = "override"
+ final val PACKAGEkw: NameType = "package"
+ final val PRIVATEkw: NameType = "private"
+ final val PROTECTEDkw: NameType = "protected"
+ final val RETURNkw: NameType = "return"
+ final val REQUIRESkw: NameType = "requires"
+ final val SEALEDkw: NameType = "sealed"
+ final val SUPERkw: NameType = "super"
+ final val THISkw: NameType = "this"
+ final val THROWkw: NameType = "throw"
+ final val TRAITkw: NameType = "trait"
+ final val TRUEkw: NameType = "true"
+ final val TRYkw: NameType = "try"
+ final val TYPEkw: NameType = "type"
+ final val VALkw: NameType = "val"
+ final val VARkw: NameType = "var"
+ final val WITHkw: NameType = "with"
+ final val WHILEkw: NameType = "while"
+ final val YIELDkw: NameType = "yield"
+ final val DOTkw: NameType = "."
+ final val USCOREkw: NameType = "_"
+ final val COLONkw: NameType = ":"
+ final val EQUALSkw: NameType = "="
+ final val ARROWkw: NameType = "=>"
+ final val LARROWkw: NameType = "<-"
+ final val SUBTYPEkw: NameType = "<:"
+ final val VIEWBOUNDkw: NameType = "<%"
+ final val SUPERTYPEkw: NameType = ">:"
+ final val HASHkw: NameType = "#"
+ final val ATkw: NameType = "@"
+
+ // Compiler internal names
+ val ANYNAME: NameType = "<anyname>"
+ val CONSTRUCTOR: NameType = "<init>"
+ val FAKE_LOCAL_THIS: NameType = "this$"
+ val INITIALIZER: NameType = CONSTRUCTOR // Is this buying us something?
+ val MIXIN_CONSTRUCTOR: NameType = "$init$"
+ val MODULE_INSTANCE_FIELD: NameType = "MODULE$"
+ val OUTER: NameType = "$outer"
+ val OUTER_LOCAL: NameType = "$outer " // note the space
+ val SELF: NameType = "$this"
+ val SPECIALIZED_INSTANCE: NameType = "specInstance$"
+ val THIS: NameType = "_$this"
+
+ // Compiler utilized names
+ // val productElementName: NameType = "productElementName"
+ val TYPE_ : NameType = "TYPE"
+ val add_ : NameType = "add"
+ val apply: NameType = "apply"
+ val arrayValue: NameType = "arrayValue"
+ val arraycopy: NameType = "arraycopy"
+ val asInstanceOf_ : NameType = "asInstanceOf"
+ val assert_ : NameType = "assert"
+ val assume_ : NameType = "assume"
+ val box: NameType = "box"
+ val bytes: NameType = "bytes"
+ val canEqual_ : NameType = "canEqual"
+ val checkInitialized: NameType = "checkInitialized"
+ val classOf: NameType = "classOf"
+ val clone_ : NameType = "clone"
+ val conforms: NameType = "conforms"
+ val copy: NameType = "copy"
+ val delayedInit: NameType = "delayedInit"
+ val delayedInitArg: NameType = "delayedInit$body"
+ val dottype: NameType = ".type"
+ val drop: NameType = "drop"
+ val elem: NameType = "elem"
+ val eq: NameType = "eq"
+ val equals_ : NameType = "equals"
+ val error: NameType = "error"
+ val ex: NameType = "ex"
+ val false_ : NameType = "false"
+ val filter: NameType = "filter"
+ val finalize_ : NameType = "finalize"
+ val find_ : NameType = "find"
+ val flatMap: NameType = "flatMap"
+ val foreach: NameType = "foreach"
+ val genericArrayOps: NameType = "genericArrayOps"
+ val get: NameType = "get"
+ val hasNext: NameType = "hasNext"
+ val hashCode_ : NameType = "hashCode"
+ val hash_ : NameType = "hash"
+ val head: NameType = "head"
+ val identity: NameType = "identity"
+ val inlinedEquals: NameType = "inlinedEquals"
+ val isArray: NameType = "isArray"
+ val isDefinedAt: NameType = "isDefinedAt"
+ val isEmpty: NameType = "isEmpty"
+ val isInstanceOf_ : NameType = "isInstanceOf"
+ val java: NameType = "java"
+ val lang: NameType = "lang"
+ val length: NameType = "length"
+ val lengthCompare: NameType = "lengthCompare"
+ val lift_ : NameType = "lift"
+ val main: NameType = "main"
+ val map: NameType = "map"
+ val ne: NameType = "ne"
+ val newArray: NameType = "newArray"
+ val next: NameType = "next"
+ val notifyAll_ : NameType = "notifyAll"
+ val notify_ : NameType = "notify"
+ val null_ : NameType = "null"
+ val ofDim: NameType = "ofDim"
+ val productArity: NameType = "productArity"
+ val productElement: NameType = "productElement"
+ val productPrefix: NameType = "productPrefix"
+ val readResolve: NameType = "readResolve"
+ val sameElements: NameType = "sameElements"
+ val scala_ : NameType = "scala"
+ val self: NameType = "self"
+ val setAccessible: NameType = "setAccessible"
+ val synchronized_ : NameType = "synchronized"
+ val tail: NameType = "tail"
+ val this_ : NameType = "this"
+ val throw_ : NameType = "throw"
+ val toArray: NameType = "toArray"
+ val toList: NameType = "toList"
+ val toSeq: NameType = "toSeq"
+ val toString_ : NameType = "toString"
+ val true_ : NameType = "true"
+ val unapply: NameType = "unapply"
+ val unapplySeq: NameType = "unapplySeq"
+ val unbox: NameType = "unbox"
+ val update: NameType = "update"
+ val value: NameType = "value"
+ val view_ : NameType = "view"
+ val wait_ : NameType = "wait"
+ val withFilter: NameType = "withFilter"
+ val zip: NameType = "zip"
+
+ // unencoded operators
+ object raw {
+ final val AMP : NameType = "&"
+ final val BANG : NameType = "!"
+ final val BAR : NameType = "|"
+ final val DOLLAR: NameType = "$"
+ final val GE: NameType = ">="
+ final val LE: NameType = "<="
+ final val MINUS: NameType = "-"
+ final val NE: NameType = "!="
+ final val PLUS : NameType = "+"
+ final val SLASH: NameType = "/"
+ final val STAR : NameType = "*"
+ final val TILDE: NameType = "~"
+
+ final val isUnary: Set[Name] = Set(MINUS, PLUS, TILDE, BANG)
+ }
+
+ // value-conversion methods
+ val toByte: NameType = "toByte"
+ val toShort: NameType = "toShort"
+ val toChar: NameType = "toChar"
+ val toInt: NameType = "toInt"
+ val toLong: NameType = "toLong"
+ val toFloat: NameType = "toFloat"
+ val toDouble: NameType = "toDouble"
+ }
+
+ trait CompilerTypeNames extends CompilerCommonNames {
+ final val BYNAME_PARAM_CLASS_NAME: NameType = "<byname>"
+ final val EQUALS_PATTERN_NAME: NameType = "<equals>"
+ final val JAVA_REPEATED_PARAM_CLASS_NAME: NameType = "<repeated...>"
+ final val LOCAL_CHILD: NameType = "<local child>"
+ final val REPEATED_PARAM_CLASS_NAME: NameType = "<repeated>"
+ final val WILDCARD_STAR: NameType = "_*"
+
+ final val Nothing: NameType = "Nothing"
+ final val Null: NameType = "Null"
+ final val Serializable: NameType = "Serializable"
+ final val Singleton: NameType = "Singleton"
+ final val Throwable: NameType = "Throwable"
+
+ // Stores Java annotations on parameters with RetentionPolicy.RUNTIME
+ // Stores Java annotations with RetentionPolicy.CLASS. Currently not used (Apr 2009).
+ // Stores Java annotations with RetentionPolicy.RUNTIME
+ final val AnnotationDefaultATTR: NameType = "AnnotationDefault"
+ final val BridgeATTR: NameType = "Bridge"
+ final val ClassfileAnnotationATTR: NameType = "RuntimeInvisibleAnnotations"
+ final val CodeATTR: NameType = "Code"
+ final val ConstantValueATTR: NameType = "ConstantValue"
+ final val DeprecatedATTR: NameType = "Deprecated"
+ final val ExceptionsATTR: NameType = "Exceptions"
+ final val InnerClassesATTR: NameType = "InnerClasses"
+ final val JacoMetaATTR: NameType = "JacoMeta"
+ final val LineNumberTableATTR: NameType = "LineNumberTable"
+ final val LocalVariableTableATTR: NameType = "LocalVariableTable"
+ final val RuntimeAnnotationATTR: NameType = "RuntimeVisibleAnnotations"
+ final val RuntimeParamAnnotationATTR: NameType = "RuntimeVisibleParameterAnnotations"
+ final val ScalaATTR: NameType = "Scala"
+ final val ScalaSignatureATTR: NameType = "ScalaSig"
+ final val SignatureATTR: NameType = "Signature"
+ final val SourceFileATTR: NameType = "SourceFile"
+ final val SyntheticATTR: NameType = "Synthetic"
+ }
+
+ object tpnme extends CompilerTypeNames with LibraryTypeNames {
+ type NameType = TypeName
+ implicit def createNameType(name: String): TypeName = newTypeName(name)
+ }
+
+ object nme extends CompilerTermNames with LibraryTermNames with NameMangling {
+ type NameType = TermName
+ implicit def createNameType(name: String): TermName = newTermName(name)
/** Translate a String into a list of simple TypeNames and TermNames.
* In all segments before the last, type/term is determined by whether
@@ -49,429 +308,181 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
}
}
- // Scala keywords
- val ABSTRACTkw = newTermName("abstract")
- val CASEkw = newTermName("case")
- val CLASSkw = newTermName("class")
- val CATCHkw = newTermName("catch")
- val DEFkw = newTermName("def")
- val DOkw = newTermName("do")
- val ELSEkw = newTermName("else")
- val EXTENDSkw = newTermName("extends")
- val FALSEkw = newTermName("false")
- val FINALkw = newTermName("final")
- val FINALLYkw = newTermName("finally")
- val FORkw = newTermName("for")
- val FORSOMEkw = newTermName("forSome")
- val IFkw = newTermName("if")
- val IMPLICITkw = newTermName("implicit")
- val IMPORTkw = newTermName("import")
- val LAZYkw = newTermName("lazy")
- val MATCHkw = newTermName("match")
- val NEWkw = newTermName("new")
- val NULLkw = newTermName("null")
- val OBJECTkw = newTermName("object")
- val OVERRIDEkw = newTermName("override")
- val PACKAGEkw = newTermName("package")
- val PRIVATEkw = newTermName("private")
- val PROTECTEDkw = newTermName("protected")
- val RETURNkw = newTermName("return")
- val REQUIRESkw = newTermName("requires")
- val SEALEDkw = newTermName("sealed")
- val SUPERkw = newTermName("super")
- val THISkw = newTermName("this")
- val THROWkw = newTermName("throw")
- val TRAITkw = newTermName("trait")
- val TRUEkw = newTermName("true")
- val TRYkw = newTermName("try")
- val TYPEkw = newTermName("type")
- val VALkw = newTermName("val")
- val VARkw = newTermName("var")
- val WITHkw = newTermName("with")
- val WHILEkw = newTermName("while")
- val YIELDkw = newTermName("yield")
- val DOTkw = newTermName(".")
- val USCOREkw = newTermName("_")
- val COLONkw = newTermName(":")
- val EQUALSkw = newTermName("=")
- val ARROWkw = newTermName("=>")
- val LARROWkw = newTermName("<-")
- val SUBTYPEkw = newTermName("<:")
- val VIEWBOUNDkw = newTermName("<%")
- val SUPERTYPEkw = newTermName(">:")
- val HASHkw = newTermName("#")
- val ATkw = newTermName("@")
-
- val INTERPRETER_IMPORT_WRAPPER = "$iw"
- val INTERPRETER_LINE_PREFIX = "line"
- val INTERPRETER_SYNTHVAR_PREFIX = "synthvar$"
- val INTERPRETER_VAR_PREFIX = "res"
- val INTERPRETER_WRAPPER_SUFFIX = "$object"
-
- private def bitmapName(n: Int, suffix: String): Name =
+ private def bitmapName(n: Int, suffix: String): TermName =
newTermName(BITMAP_PREFIX + suffix + n)
/** The name of bitmaps for initialized (public or protected) lazy vals. */
- def bitmapName(n: Int): Name = bitmapName(n, "")
+ def bitmapName(n: Int): TermName = bitmapName(n, "")
/** The name of bitmaps for initialized transient lazy vals. */
- def bitmapNameForTransitive(n: Int): Name = bitmapName(n, "trans$")
+ def bitmapNameForTransitive(n: Int): TermName = bitmapName(n, "trans$")
/** The name of bitmaps for initialized private lazy vals. */
- def bitmapNameForPrivate(n: Int): Name = bitmapName(n, "priv$")
+ def bitmapNameForPrivate(n: Int): TermName = bitmapName(n, "priv$")
/** Base strings from which synthetic names are derived. */
- val BITMAP_PREFIX = "bitmap$"
- val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$"
- val DEFAULT_GETTER_STRING = "$default$"
- val DO_WHILE_PREFIX = "doWhile$"
- val EQEQ_LOCAL_VAR = "eqEqTemp$"
- val EVIDENCE_PARAM_PREFIX = "evidence$"
- val EXCEPTION_RESULT_PREFIX = "exceptionResult"
- val WHILE_PREFIX = "while$"
-
- /** Internal names */
- val ANYNAME = newTermName("<anyname>")
- val EQUALS_PATTERN_NAME = newTermName("<equals>")
- val ERROR = newTermName("<error>")
- val NOSYMBOL = newTermName("<none>")
-
- /** TYPE names. */
- val BYNAME_PARAM_CLASS_NAME = newTypeName("<byname>")
- val JAVA_REPEATED_PARAM_CLASS_NAME = newTypeName("<repeated...>")
- val LOCALCHILD = newTypeName("<local child>")
- val REPEATED_PARAM_CLASS_NAME = newTypeName("<repeated>")
- val WILDCARD_STAR = newTypeName("_*")
-
- val CONSTRUCTOR = newTermName("<init>")
- val INITIALIZER = newTermName("<init>")
- val INLINED_INITIALIZER = newTermName("$init$")
- val MIXIN_CONSTRUCTOR = newTermName("$init$")
-
- val OUTER = newTermName("$outer")
- val OUTER_LOCAL = newTermName("$outer ")
- val SELF = newTermName("$this")
- val THIS = newTermName("_$this")
- val FAKE_LOCAL_THIS = newTermName("this$")
-
- val MODULE_INSTANCE_FIELD = newTermName("MODULE$")
- val SPECIALIZED_INSTANCE = newTermName("specInstance$")
-
- val TYPE_ = newTermName("TYPE")
- val WILDCARD = newTermName("_")
- val STAR = newTermName("*")
-
- val MINUS = encode("-")
- val PLUS = encode("+")
- val PLUSPLUS = encode("++")
- val TILDE = encode("~")
- val BANG = encode("!")
- val BANGEQ = encode("!=")
- val BARBAR = encode("||")
- val AMPAMP = encode("&&")
- val COLONCOLON = encode("::")
- val PERCENT = encode("%")
- val EQL = encode("=")
- val HASHHASH = encode("##")
-
- val Nothing = newTermName("Nothing")
- val Null = newTermName("Null")
- val Any = newTermName("Any")
- val AnyVal = newTermName("AnyVal")
- val AnyRef = newTermName("AnyRef")
- val Array = newTermName("Array")
- val Boolean = newTermName("Boolean")
- val Byte = newTermName("Byte")
- val Char = newTermName("Char")
- val Do = newTermName("Do")
- val Double = newTermName("Double")
- val Float = newTermName("Float")
- val Function = newTermName("Function")
- val Int = newTermName("Int")
- val List = newTermName("List")
- val Long = newTermName("Long")
- val Nil = newTermName("Nil")
- val Object = newTermName("Object")
- val PartialFunction = newTermName("PartialFunction")
- val Predef = newTermName("Predef")
- val Product = newTermName("Product")
- val ScalaObject = newTermName("ScalaObject")
- val ScalaRunTime = newTermName("ScalaRunTime")
- val Seq = newTermName("Seq")
- val Serializable = newTermName("Serializable")
- val Short = newTermName("Short")
- val Singleton = newTermName("Singleton")
- val Some = newTermName("Some")
- val String = newTermName("String")
- val Symbol = newTermName("Symbol")
- val System = newTermName("System")
- val Throwable = newTermName("Throwable")
- val Tuple = newTermName("Tuple")
- val Unit = newTermName("Unit")
-
- val apply = newTermName("apply")
- val arrayValue = newTermName("arrayValue")
- val arraycopy = newTermName("arraycopy")
- val assert_ = newTermName("assert")
- val assume_ = newTermName("assume")
- val asInstanceOf_ = newTermName("asInstanceOf")
- val box = newTermName("box")
- val bytes = newTermName("bytes")
- val canEqual_ = newTermName("canEqual")
- val checkInitialized = newTermName("checkInitialized")
- val classOf = newTermName("classOf")
- val identity = newTermName("identity")
- val conforms = newTermName("conforms")
- val copy = newTermName("copy")
- val delayedInit = newTermName("delayedInit")
- val delayedInitArg = newTermName("delayedInit$body")
- val dottype = newTermName(".type")
- val drop = newTermName("drop")
- val elem = newTermName("elem")
- val eq = newTermName("eq")
- val equals_ = newTermName("equals")
- val inlinedEquals = newTermName("inlinedEquals")
- val error = newTermName("error")
- val ex = newTermName("ex")
- val add_ = newTermName("add")
- val false_ = newTermName("false")
- val filter = newTermName("filter")
- val finalize_ = newTermName("finalize")
- val find_ = newTermName("find")
- val flatMap = newTermName("flatMap")
- val foreach = newTermName("foreach")
- val get = newTermName("get")
- def getCause = sn.GetCause
- def getClass_ = sn.GetClass
+ val BITMAP_PREFIX = "bitmap$"
+ val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$"
+ val DEFAULT_GETTER_STRING = "$default$"
+ val DO_WHILE_PREFIX = "doWhile$"
+ val EQEQ_LOCAL_VAR = "eqEqTemp$"
+ val EVIDENCE_PARAM_PREFIX = "evidence$"
+ val EXCEPTION_RESULT_PREFIX = "exceptionResult"
+ val INTERPRETER_IMPORT_WRAPPER = "$iw"
+ val INTERPRETER_LINE_PREFIX = "line"
+ val INTERPRETER_SYNTHVAR_PREFIX = "synthvar$"
+ val INTERPRETER_VAR_PREFIX = "res"
+ val INTERPRETER_WRAPPER_SUFFIX = "$object"
+ val WHILE_PREFIX = "while$"
+
+ def getCause = sn.GetCause
+ def getClass_ = sn.GetClass
def getMethod_ = sn.GetMethod
- val hash_ = newTermName("hash")
- val hashCode_ = newTermName("hashCode")
- val hasNext = newTermName("hasNext")
- val head = newTermName("head")
- def invoke_ = sn.Invoke
- val isArray = newTermName("isArray")
- val isInstanceOf_ = newTermName("isInstanceOf")
- val isDefinedAt = newTermName("isDefinedAt")
- val isEmpty = newTermName("isEmpty")
- val java = newTermName("java")
- val lang = newTermName("lang")
- val length = newTermName("length")
- val lengthCompare = newTermName("lengthCompare")
- val lift_ = newTermName("lift")
- val main = newTermName("main")
- val map = newTermName("map")
- val ne = newTermName("ne")
- val newArray = newTermName("newArray")
- val next = newTermName("next")
- val notify_ = newTermName("notify")
- val notifyAll_ = newTermName("notifyAll")
- val null_ = newTermName("null")
- val ofDim = newTermName("ofDim")
- val productArity = newTermName("productArity")
- val productElement = newTermName("productElement")
- // val productElementName = newTermName("productElementName")
- val productPrefix = newTermName("productPrefix")
- val readResolve = newTermName("readResolve")
- val sameElements = newTermName("sameElements")
- val scala_ = newTermName("scala")
- val self = newTermName("self")
- val setAccessible = newTermName("setAccessible")
- val synchronized_ = newTermName("synchronized")
- val tail = newTermName("tail")
- val toArray = newTermName("toArray")
- val toList = newTermName("toList")
- val toSeq = newTermName("toSeq")
- val toString_ = newTermName("toString")
- val clone_ = newTermName("clone")
- val this_ = newTermName("this")
- val throw_ = newTermName("throw")
- val true_ = newTermName("true")
- val unapply = newTermName("unapply")
- val unapplySeq = newTermName("unapplySeq")
- val unbox = newTermName("unbox")
- val update = newTermName("update")
- val value = newTermName("value")
- val view_ = newTermName("view")
- val wait_ = newTermName("wait")
- val withFilter = newTermName("withFilter")
- val zip = newTermName("zip")
- val genericArrayOps = newTermName("genericArrayOps")
-
- val ZAND = encode("&&")
- val ZOR = encode("||")
- val ADD = encode("+")
- val SUB = encode("-")
- val MUL = encode("*")
- val DIV = encode("/")
- val MOD = encode("%")
- val EQ = encode("==")
- val NE = encode("!=")
- val LT = encode("<")
- val LE = encode("<=")
- val GT = encode(">")
- val GE = encode(">=")
- val OR = encode("|")
- val XOR = encode("^")
- val AND = encode("&")
- val LSL = encode("<<")
- val LSR = encode(">>>")
- val ASR = encode(">>")
+ def invoke_ = sn.Invoke
+
+ val ADD = encode("+")
+ val AND = encode("&")
+ val ASR = encode(">>")
+ val DIV = encode("/")
+ val EQ = encode("==")
+ val EQL = encode("=")
+ val GE = encode(">=")
+ val GT = encode(">")
+ val HASHHASH = encode("##")
+ val LE = encode("<=")
+ val LSL = encode("<<")
+ val LSR = encode(">>>")
+ val LT = encode("<")
+ val MINUS = encode("-")
+ val MOD = encode("%")
+ val MUL = encode("*")
+ val NE = encode("!=")
+ val OR = encode("|")
+ val PLUS = encode("+")
+ val SUB = encode("-")
+ val XOR = encode("^")
+ val ZAND = encode("&&")
+ val ZOR = encode("||")
// unary operators
val UNARY_~ = encode("unary_~")
val UNARY_+ = encode("unary_+")
val UNARY_- = encode("unary_-")
val UNARY_! = encode("unary_!")
-
- // unencoded comparisons
- val EQraw = newTermName("==")
- val NEraw = newTermName("!=")
- val LEraw = newTermName("<=")
- val GEraw = newTermName(">=")
- val DOLLARraw = newTermName("$")
-
- // value-conversion methods
- val toByte = newTermName("toByte")
- val toShort = newTermName("toShort")
- val toChar = newTermName("toChar")
- val toInt = newTermName("toInt")
- val toLong = newTermName("toLong")
- val toFloat = newTermName("toFloat")
- val toDouble = newTermName("toDouble")
-
- val SourceFileATTR = newTermName("SourceFile")
- val SyntheticATTR = newTermName("Synthetic")
- val BridgeATTR = newTermName("Bridge")
- val DeprecatedATTR = newTermName("Deprecated")
- val CodeATTR = newTermName("Code")
- val ExceptionsATTR = newTermName("Exceptions")
- val ConstantValueATTR = newTermName("ConstantValue")
- val LineNumberTableATTR = newTermName("LineNumberTable")
- val LocalVariableTableATTR = newTermName("LocalVariableTable")
- val InnerClassesATTR = newTermName("InnerClasses")
- val JacoMetaATTR = newTermName("JacoMeta")
- val SignatureATTR = newTermName("Signature")
- val ScalaSignatureATTR = newTermName("ScalaSig")
- val AnnotationDefaultATTR = newTermName("AnnotationDefault")
- // Stores Java annotations with RetentionPolicy.RUNTIME
- val RuntimeAnnotationATTR = newTermName("RuntimeVisibleAnnotations")
- // Stores Java annotations with RetentionPolicy.CLASS. Currently not used (Apr 2009).
- val ClassfileAnnotationATTR = newTermName("RuntimeInvisibleAnnotations")
- // Stores Java annotations on parameters with RetentionPolicy.RUNTIME
- val RuntimeParamAnnotationATTR = newTermName("RuntimeVisibleParameterAnnotations")
- val ScalaATTR = newTermName("Scala")
}
abstract class SymbolNames {
- val BeanProperty : Name
- val BooleanBeanProperty : Name
- val BoxedBoolean : Name
- val BoxedCharacter : Name
- val BoxedNumber : Name
- val Class : Name
- val Code : Name
- val Delegate : Name
- val ForName : Name
- val GetCause : Name
- val GetClass : Name
- val GetMethod : Name
- val IOOBException : Name // IndexOutOfBoundsException
- val InvTargetException : Name // InvocationTargetException
- val Invoke : Name
- val JavaLang : Name
- val MethodAsObject : Name
- val NLRControl : Name = newTermName("scala.runtime.NonLocalReturnControl")
- val NPException : Name // NullPointerException
- val Object : Name
- val JavaSerializable : Name
- val String : Name
- val Throwable : Name
- val ValueType : Name
-
- val Boxed: immutable.Map[Name, Name]
+ val BeanProperty : TypeName
+ val BooleanBeanProperty : TypeName
+ val BoxedBoolean : TypeName
+ val BoxedCharacter : TypeName
+ val BoxedNumber : TypeName
+ val Class : TypeName
+ val Code : TypeName
+ val Delegate : TypeName
+ val IOOBException : TypeName // IndexOutOfBoundsException
+ val InvTargetException : TypeName // InvocationTargetException
+ val JavaSerializable : TypeName
+ val MethodAsObject : TypeName
+ val NPException : TypeName // NullPointerException
+ val Object : TypeName
+ val String : TypeName
+ val Throwable : TypeName
+ val ValueType : TypeName
+
+ val ForName : TermName
+ val GetCause : TermName
+ val GetClass : TermName
+ val GetMethod : TermName
+ val Invoke : TermName
+ val JavaLang : TermName
+
+ val Boxed: immutable.Map[TypeName, TypeName]
}
private abstract class JavaNames extends SymbolNames {
- final val BoxedBoolean = newTermName("java.lang.Boolean")
- final val BoxedByte = newTermName("java.lang.Byte")
- final val BoxedCharacter = newTermName("java.lang.Character")
- final val BoxedDouble = newTermName("java.lang.Double")
- final val BoxedFloat = newTermName("java.lang.Float")
- final val BoxedInteger = newTermName("java.lang.Integer")
- final val BoxedLong = newTermName("java.lang.Long")
- final val BoxedNumber = newTermName("java.lang.Number")
- final val BoxedShort = newTermName("java.lang.Short")
- final val Class = newTermName("java.lang.Class")
- final val Delegate = nme.NOSYMBOL
- final val ForName = newTermName("forName")
- final val GetCause = newTermName("getCause")
- final val GetClass = newTermName("getClass")
- final val GetMethod = newTermName("getMethod")
- final val IOOBException = newTermName("java.lang.IndexOutOfBoundsException")
- final val InvTargetException = newTermName("java.lang.reflect.InvocationTargetException")
- final val Invoke = newTermName("invoke")
- final val JavaLang = newTermName("java.lang")
- final val MethodAsObject = newTermName("java.lang.reflect.Method")
- final val NPException = newTermName("java.lang.NullPointerException")
- final val Object = newTermName("java.lang.Object")
- final val String = newTermName("java.lang.String")
- final val Throwable = newTermName("java.lang.Throwable")
- final val ValueType = nme.NOSYMBOL
-
- val Boxed = immutable.Map[Name, Name](
- nme.Boolean -> BoxedBoolean,
- nme.Byte -> BoxedByte,
- nme.Char -> BoxedCharacter,
- nme.Short -> BoxedShort,
- nme.Int -> BoxedInteger,
- nme.Long -> BoxedLong,
- nme.Float -> BoxedFloat,
- nme.Double -> BoxedDouble
+ final val BoxedBoolean: TypeName = "java.lang.Boolean"
+ final val BoxedByte: TypeName = "java.lang.Byte"
+ final val BoxedCharacter: TypeName = "java.lang.Character"
+ final val BoxedDouble: TypeName = "java.lang.Double"
+ final val BoxedFloat: TypeName = "java.lang.Float"
+ final val BoxedInteger: TypeName = "java.lang.Integer"
+ final val BoxedLong: TypeName = "java.lang.Long"
+ final val BoxedNumber: TypeName = "java.lang.Number"
+ final val BoxedShort: TypeName = "java.lang.Short"
+ final val Class: TypeName = "java.lang.Class"
+ final val Delegate: TypeName = tpnme.NO_NAME
+ final val IOOBException: TypeName = "java.lang.IndexOutOfBoundsException"
+ final val InvTargetException: TypeName = "java.lang.reflect.InvocationTargetException"
+ final val MethodAsObject: TypeName = "java.lang.reflect.Method"
+ final val NPException: TypeName = "java.lang.NullPointerException"
+ final val Object: TypeName = "java.lang.Object"
+ final val String: TypeName = "java.lang.String"
+ final val Throwable: TypeName = "java.lang.Throwable"
+ final val ValueType: TypeName = tpnme.NO_NAME
+
+ final val ForName: TermName = "forName"
+ final val GetCause: TermName = "getCause"
+ final val GetClass: TermName = "getClass"
+ final val GetMethod: TermName = "getMethod"
+ final val Invoke: TermName = "invoke"
+ final val JavaLang: TermName = "java.lang"
+
+ val Boxed = immutable.Map[TypeName, TypeName](
+ tpnme.Boolean -> BoxedBoolean,
+ tpnme.Byte -> BoxedByte,
+ tpnme.Char -> BoxedCharacter,
+ tpnme.Short -> BoxedShort,
+ tpnme.Int -> BoxedInteger,
+ tpnme.Long -> BoxedLong,
+ tpnme.Float -> BoxedFloat,
+ tpnme.Double -> BoxedDouble
)
}
private class MSILNames extends SymbolNames {
- final val BeanProperty = nme.NOSYMBOL
- final val BooleanBeanProperty = nme.NOSYMBOL
- final val BoxedBoolean = newTermName("System.IConvertible")
- final val BoxedCharacter = newTermName("System.IConvertible")
- final val BoxedNumber = newTermName("System.IConvertible")
- final val Class = newTermName("System.Type")
- final val Code = nme.NOSYMBOL
- final val Delegate = newTermName("System.MulticastDelegate")
- final val ForName = newTermName("GetType")
- final val GetCause = newTermName("InnerException") /* System.Reflection.TargetInvocationException.InnerException */
- final val GetClass = newTermName("GetType")
- final val GetMethod = newTermName("GetMethod")
- final val IOOBException = newTermName("System.IndexOutOfRangeException")
- final val InvTargetException = newTermName("System.Reflection.TargetInvocationException")
- final val Invoke = newTermName("Invoke")
- final val JavaLang = newTermName("System")
- final val MethodAsObject = newTermName("System.Reflection.MethodInfo")
- final val NPException = newTermName("System.NullReferenceException")
- final val Object = newTermName("System.Object")
- final val JavaSerializable = nme.NOSYMBOL
- final val String = newTermName("System.String")
- final val Throwable = newTermName("System.Exception")
- final val ValueType = newTermName("System.ValueType")
-
- val Boxed = immutable.Map[Name, Name](
- nme.Boolean -> newTermName("System.Boolean"),
- nme.Byte -> newTermName("System.Byte"),
- nme.Char -> newTermName("System.Char"),
- nme.Short -> newTermName("System.Int16"),
- nme.Int -> newTermName("System.Int32"),
- nme.Long -> newTermName("System.Int64"),
- nme.Float -> newTermName("System.Single"),
- nme.Double -> newTermName("System.Double")
+ final val BeanProperty: TypeName = tpnme.NO_NAME
+ final val BooleanBeanProperty: TypeName = tpnme.NO_NAME
+ final val BoxedBoolean: TypeName = "System.IConvertible"
+ final val BoxedCharacter: TypeName = "System.IConvertible"
+ final val BoxedNumber: TypeName = "System.IConvertible"
+ final val Class: TypeName = "System.Type"
+ final val Code: TypeName = tpnme.NO_NAME
+ final val Delegate: TypeName = "System.MulticastDelegate"
+ final val IOOBException: TypeName = "System.IndexOutOfRangeException"
+ final val InvTargetException: TypeName = "System.Reflection.TargetInvocationException"
+ final val JavaSerializable: TypeName = tpnme.NO_NAME
+ final val MethodAsObject: TypeName = "System.Reflection.MethodInfo"
+ final val NPException: TypeName = "System.NullReferenceException"
+ final val Object: TypeName = "System.Object"
+ final val String: TypeName = "System.String"
+ final val Throwable: TypeName = "System.Exception"
+ final val ValueType: TypeName = "System.ValueType"
+
+ final val ForName: TermName = "GetType"
+ final val GetCause: TermName = "InnerException" /* System.Reflection.TargetInvocationException.InnerException */
+ final val GetClass: TermName = "GetType"
+ final val GetMethod: TermName = "GetMethod"
+ final val Invoke: TermName = "Invoke"
+ final val JavaLang: TermName = "System"
+
+ val Boxed = immutable.Map[TypeName, TypeName](
+ tpnme.Boolean -> "System.Boolean",
+ tpnme.Byte -> "System.Byte",
+ tpnme.Char -> "System.Char",
+ tpnme.Short -> "System.Int16",
+ tpnme.Int -> "System.Int32",
+ tpnme.Long -> "System.Int64",
+ tpnme.Float -> "System.Single",
+ tpnme.Double -> "System.Double"
)
}
private class J2SENames extends JavaNames {
- final val BeanProperty = newTermName("scala.reflect.BeanProperty")
- final val BooleanBeanProperty = newTermName("scala.reflect.BooleanBeanProperty")
- final val Code = newTermName("scala.reflect.Code")
- final val JavaSerializable = newTermName("java.io.Serializable")
+ final val BeanProperty: TypeName = "scala.reflect.BeanProperty"
+ final val BooleanBeanProperty: TypeName = "scala.reflect.BooleanBeanProperty"
+ final val Code: TypeName = "scala.reflect.Code"
+ final val JavaSerializable: TypeName = "java.io.Serializable"
}
lazy val sn: SymbolNames =
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
index 695e95b72d..d168c259e9 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala
@@ -109,9 +109,8 @@ abstract class SymbolLoaders {
def enterClassAndModule(root: Symbol, name: String, completer: SymbolLoader) {
val owner = if (root.isRoot) definitions.EmptyPackageClass else root
- val className = newTermName(name)
assert(owner.info.decls.lookup(name) == NoSymbol, owner.fullName + "." + name)
- val clazz = owner.newClass(NoPosition, name.toTypeName)
+ val clazz = owner.newClass(NoPosition, newTypeName(name))
val module = owner.newModule(NoPosition, name)
clazz setInfo completer
module setInfo completer
@@ -167,7 +166,7 @@ abstract class SymbolLoaders {
// if there's a $member object, enter its members as well.
val pkgModule = root.info.decl(nme.PACKAGEkw)
if (pkgModule.isModule && !pkgModule.rawInfo.isInstanceOf[SourcefileLoader]) {
- //println("open "+pkgModule)//DEBUG
+ // println("open "+pkgModule)//DEBUG
openPackageModule(pkgModule)()
}
}
@@ -233,7 +232,6 @@ abstract class SymbolLoaders {
protected def newPackageLoader(pkg: ClassPath[MSILType]) =
new NamespaceLoader(pkg)
-
}
class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader {
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 31992c5d0b..81cd62d550 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -39,7 +39,6 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
/** The class for all symbols */
abstract class Symbol(initOwner: Symbol, initPos: Position, initName: Name) extends AbsSymbol {
-
var rawowner = initOwner
/** The original owner of this class. Used by the backend to generate
@@ -108,36 +107,36 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
// Creators -------------------------------------------------------------------
- final def newValue(pos: Position, name: Name) =
+ final def newValue(pos: Position, name: TermName) =
new TermSymbol(this, pos, name)
- final def newValue(name: Name, pos: Position = NoPosition) =
+ final def newValue(name: TermName, pos: Position = NoPosition) =
new TermSymbol(this, pos, name)
- final def newVariable(pos: Position, name: Name) =
+ final def newVariable(pos: Position, name: TermName) =
newValue(pos, name).setFlag(MUTABLE)
- final def newValueParameter(pos: Position, name: Name) =
+ final def newValueParameter(pos: Position, name: TermName) =
newValue(pos, name).setFlag(PARAM)
/** Create local dummy for template (owner of local blocks) */
final def newLocalDummy(pos: Position) =
newValue(pos, nme.localDummyName(this)).setInfo(NoType)
- final def newMethod(pos: Position, name: Name) =
+ final def newMethod(pos: Position, name: TermName) =
new MethodSymbol(this, pos, name).setFlag(METHOD)
- final def newMethod(name: Name, pos: Position = NoPosition) =
+ final def newMethod(name: TermName, pos: Position = NoPosition) =
new MethodSymbol(this, pos, name).setFlag(METHOD)
- final def newLabel(pos: Position, name: Name) =
+ final def newLabel(pos: Position, name: TermName) =
newMethod(pos, name).setFlag(LABEL)
final def newConstructor(pos: Position) =
newMethod(pos, nme.CONSTRUCTOR)
- final def newModule(pos: Position, name: Name, clazz: ClassSymbol) =
+ final def newModule(pos: Position, name: TermName, clazz: ClassSymbol) =
new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
.setModuleClass(clazz)
- final def newModule(name: Name, clazz: Symbol, pos: Position = NoPosition) =
+ final def newModule(name: TermName, clazz: Symbol, pos: Position = NoPosition) =
new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
.setModuleClass(clazz.asInstanceOf[ClassSymbol])
- final def newModule(pos: Position, name: Name) = {
+ final def newModule(pos: Position, name: TermName) = {
val m = new ModuleSymbol(this, pos, name).setFlag(MODULE | FINAL)
m.setModuleClass(new ModuleClassSymbol(m))
}
- final def newPackage(pos: Position, name: Name) = {
+ final def newPackage(pos: Position, name: TermName) = {
assert(name == nme.ROOT || isPackageClass)
val m = newModule(pos, name).setFlag(JAVA | PACKAGE)
m.moduleClass.setFlag(JAVA | PACKAGE)
@@ -167,7 +166,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
* pre.memberType(m)
*/
final def newOverloaded(pre: Type, alternatives: List[Symbol]): Symbol =
- newValue(alternatives.head.pos, alternatives.head.name)
+ newValue(alternatives.head.pos, alternatives.head.name.toTermName)
.setFlag(OVERLOADED)
.setInfo(OverloadedType(pre, alternatives))
@@ -181,26 +180,26 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
sym
}
- final def newErrorValue(name: Name) =
+ final def newErrorValue(name: TermName) =
newValue(pos, name).setFlag(SYNTHETIC | IS_ERROR).setInfo(ErrorType)
/** Symbol of a type definition type T = ...
*/
- final def newAliasType(pos: Position, name: Name) =
+ final def newAliasType(pos: Position, name: TypeName) =
new TypeSymbol(this, pos, name)
- final def newAliasType(name: Name, pos: Position = NoPosition) =
+ final def newAliasType(name: TypeName, pos: Position = NoPosition) =
new TypeSymbol(this, pos, name)
/** Symbol of an abstract type type T >: ... <: ...
*/
- final def newAbstractType(pos: Position, name: Name) =
+ final def newAbstractType(pos: Position, name: TypeName) =
new TypeSymbol(this, pos, name).setFlag(DEFERRED)
- final def newAbstractType(name: Name, pos: Position = NoPosition) =
+ final def newAbstractType(name: TypeName, pos: Position = NoPosition) =
new TypeSymbol(this, pos, name).setFlag(DEFERRED)
/** Symbol of a type parameter
*/
- final def newTypeParameter(pos: Position, name: Name) =
+ final def newTypeParameter(pos: Position, name: TypeName) =
newAbstractType(pos, name).setFlag(PARAM)
/** Synthetic value parameters when parameter symbols are not available
@@ -220,8 +219,8 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
* @param owner The owner of the variable
* @param bounds The variable's bounds
*/
- final def newExistential(pos: Position, name: Name): Symbol =
- newAbstractType(pos, name.toTypeName).setFlag(EXISTENTIAL)
+ final def newExistential(pos: Position, name: TypeName): Symbol =
+ newAbstractType(pos, name).setFlag(EXISTENTIAL)
final def freshExistential(suffix: String): Symbol =
newExistential(pos, freshExistentialName()+suffix)
@@ -247,27 +246,26 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
new TypeSkolem(owner, pos, name, this)
.setFlag(flags)
- final def newClass(pos: Position, name: Name) =
+ final def newClass(pos: Position, name: TypeName) =
new ClassSymbol(this, pos, name)
- final def newClass(name: Name, pos: Position = NoPosition) =
+ final def newClass(name: TypeName, pos: Position = NoPosition) =
new ClassSymbol(this, pos, name)
- final def newModuleClass(pos: Position, name: Name) =
+ final def newModuleClass(pos: Position, name: TypeName) =
new ModuleClassSymbol(this, pos, name)
- final def newModuleClass(name: Name, pos: Position = NoPosition) =
+ final def newModuleClass(name: TypeName, pos: Position = NoPosition) =
new ModuleClassSymbol(this, pos, name)
final def newAnonymousClass(pos: Position) =
- newClass(pos, nme.ANON_CLASS_NAME.toTypeName)
-
+ newClass(pos, tpnme.ANON_CLASS_NAME)
final def newAnonymousFunctionClass(pos: Position) =
- newClass(pos, nme.ANON_FUN_NAME.toTypeName)
+ newClass(pos, tpnme.ANON_FUN_NAME)
/** Refinement types P { val x: String; type T <: Number }
* also have symbols, they are refinementClasses
*/
final def newRefinementClass(pos: Position) =
- newClass(pos, nme.REFINE_CLASS_NAME.toTypeName)
+ newClass(pos, tpnme.REFINE_CLASS_NAME)
/** Create a new getter for current symbol (which must be a field)
*/
@@ -277,14 +275,15 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
getter.setInfo(MethodType(List(), tpe))
}
- final def newErrorClass(name: Name) = {
+ final def newErrorClass(name: TypeName) = {
val clazz = newClass(pos, name).setFlag(SYNTHETIC | IS_ERROR)
clazz.setInfo(ClassInfoType(List(), new ErrorScope(this), clazz))
clazz
}
final def newErrorSymbol(name: Name): Symbol =
- if (name.isTypeName) newErrorClass(name) else newErrorValue(name)
+ if (name.isTypeName) newErrorClass(name)
+ else newErrorValue(name)
// Locking and unlocking ------------------------------------------------------
@@ -371,8 +370,8 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
// class C extends D( { class E { ... } ... } ). Here, E is a class local to a constructor
final def isClassLocalToConstructor = isClass && hasFlag(INCONSTRUCTOR)
- final def isAnonymousClass = isClass && (name containsName nme.ANON_CLASS_NAME) // todo: find out why we can't use containsName here.
- final def isAnonymousFunction = hasFlag(SYNTHETIC) && (name containsName nme.ANON_FUN_NAME)
+ final def isAnonymousClass = isClass && (name containsName tpnme.ANON_CLASS_NAME)
+ final def isAnonymousFunction = isSynthetic && (name containsName tpnme.ANON_FUN_NAME)
final def isClassOfModule = isModuleClass || isClass && nme.isLocalName(name)
final def isPackageObject = isModule && name == nme.PACKAGEkw && owner.isPackageClass
@@ -866,9 +865,8 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
val current = phase
try {
while ((phase.prev ne NoPhase) && phase.prev.keepsTypeParams) phase = phase.prev
-// while (phase.keepsTypeParams && (phase.prev ne NoPhase)) phase = phase.prev
if (phase ne current) phase = phase.next
- if (settings.debug.value && (phase ne current))
+ if (settings.debug.value && settings.verbose.value && (phase ne current))
log("checking unsafeTypeParams(" + this + ") at: " + current + " reading at: " + phase)
rawInfo.typeParams
} finally {
@@ -1452,7 +1450,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
setter(owner).expandName(base)
}
name = nme.expandedName(name, base)
- if (isType) name = name.toTypeName
+ if (isType) name = name
}
}
/* code for fixing nested objects
@@ -1654,7 +1652,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
}
/** A class for term symbols */
- class TermSymbol(initOwner: Symbol, initPos: Position, initName: Name)
+ class TermSymbol(initOwner: Symbol, initPos: Position, initName: TermName)
extends Symbol(initOwner, initPos, initName) {
override def isTerm = true
@@ -1741,7 +1739,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
}
/** A class for module symbols */
- class ModuleSymbol(initOwner: Symbol, initPos: Position, initName: Name)
+ class ModuleSymbol(initOwner: Symbol, initPos: Position, initName: TermName)
extends TermSymbol(initOwner, initPos, initName) {
private var flatname = nme.EMPTY
// This method could use a better name from someone clearer on what the condition expresses.
@@ -1751,7 +1749,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
if (isFlatAdjusted) rawowner.owner
else rawowner
- override def name: Name =
+ override def name: TermName =
if (isFlatAdjusted) {
if (flatname == nme.EMPTY) {
assert(rawowner.isClass, "fatal: %s has owner %s, but a class owner is required".format(rawname, rawowner))
@@ -1765,7 +1763,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
}
/** A class for method symbols */
- class MethodSymbol(initOwner: Symbol, initPos: Position, initName: Name)
+ class MethodSymbol(initOwner: Symbol, initPos: Position, initName: TermName)
extends TermSymbol(initOwner, initPos, initName) {
private var mtpePeriod = NoPeriod
@@ -1795,7 +1793,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
/** A class of type symbols. Alias and abstract types are direct instances
* of this class. Classes are instances of a subclass.
*/
- class TypeSymbol(initOwner: Symbol, initPos: Position, initName: Name)
+ class TypeSymbol(initOwner: Symbol, initPos: Position, initName: TypeName)
extends Symbol(initOwner, initPos, initName) {
privateWithin = NoSymbol
private var tyconCache: Type = null
@@ -1897,7 +1895,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
* origin.isInstanceOf[Symbol] == !hasFlag(EXISTENTIAL)
*/
class TypeSkolem(initOwner: Symbol, initPos: Position,
- initName: Name, origin: AnyRef)
+ initName: TypeName, origin: AnyRef)
extends TypeSymbol(initOwner, initPos, initName) {
/** The skolemization level in place when the skolem was constructed */
@@ -1926,7 +1924,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
/** A class for class symbols */
- class ClassSymbol(initOwner: Symbol, initPos: Position, initName: Name)
+ class ClassSymbol(initOwner: Symbol, initPos: Position, initName: TypeName)
extends TypeSymbol(initOwner, initPos, initName) {
/** The classfile from which this class was loaded. Maybe null. */
@@ -1956,17 +1954,17 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
thissym = this
}
- private var flatname = nme.EMPTY
+ private var flatname: TypeName = tpnme.EMPTY
override def owner: Symbol =
if (phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass) rawowner.owner
else rawowner
- override def name: Name =
+ override def name: TypeName =
if ((rawflags & notDEFERRED) != 0L && phase.devirtualized && !phase.erasedTypes) {
newTypeName(rawname+"$trait") // (part of DEVIRTUALIZE)
} else if (phase.flatClasses && rawowner != NoSymbol && !rawowner.isPackageClass) {
- if (flatname == nme.EMPTY) {
+ if (flatname == tpnme.EMPTY) {
assert(rawowner.isClass, "fatal: %s has owner %s, but a class owner is required".format(rawname+idString, rawowner))
flatname = newTypeName(compactify(rawowner.name.toString() + "$" + rawname))
}
@@ -2024,7 +2022,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
* Note: Not all module classes are of this type; when unpickled, we get
* plain class symbols!
*/
- class ModuleClassSymbol(owner: Symbol, pos: Position, name: Name)
+ class ModuleClassSymbol(owner: Symbol, pos: Position, name: TypeName)
extends ClassSymbol(owner, pos, name) {
private var module: Symbol = null
def this(module: TermSymbol) = {
@@ -2038,7 +2036,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
}
/** An object representing a missing symbol */
- object NoSymbol extends Symbol(null, NoPosition, nme.NOSYMBOL) {
+ object NoSymbol extends Symbol(null, NoPosition, nme.NO_NAME) {
setInfo(NoType)
privateWithin = this
override def info_=(info: Type) {
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 972c900418..6f9b92b60f 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -3284,7 +3284,7 @@ A type's typeSymbol should never be inspected directly.
val termSym =
pre.typeSymbol.owner.newValue(
pre.typeSymbol.pos,
- pre.typeSymbol.name).setInfo(pre) // what symbol should really be used?
+ pre.typeSymbol.name.toTermName).setInfo(pre) // what symbol should really be used?
mkAttributedQualifier(pre, termSym)
} else
giveup()
@@ -4574,7 +4574,7 @@ A type's typeSymbol should never be inspected directly.
tp1.isStable || fourthTry
else if (isRaw(sym2, tp2.args))
isSubType(tp1, rawToExistential(tp2), depth)
- else if (sym2.name == nme.REFINE_CLASS_NAME.toTypeName)
+ else if (sym2.name == tpnme.REFINE_CLASS_NAME)
isSubType(tp1, sym2.info, depth)
else
fourthTry
@@ -4656,7 +4656,7 @@ A type's typeSymbol should never be inspected directly.
else if (isRaw(sym1, tr1.args))
isSubType(rawToExistential(tp1), tp2, depth)
else
- sym1.name == nme.REFINE_CLASS_NAME.toTypeName &&
+ sym1.name == tpnme.REFINE_CLASS_NAME &&
isSubType(sym1.info, tp2, depth)
case _: TypeSymbol =>
if (sym1 hasFlag DEFERRED) {
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index a051177a87..109de180a4 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -153,25 +153,30 @@ abstract class ClassfileParser {
}
}
- /** Return the name found at given index. The returned name is a term name. */
+ /** Return the name found at given index. */
def getName(index: Int): Name = {
- if (index <= 0 || len <= index) errorBadIndex(index)
- var name = values(index).asInstanceOf[Name]
- if (name eq null) {
- val start = starts(index)
- if (in.buf(start).toInt != CONSTANT_UTF8) errorBadTag(start)
- name = newTermName(in.buf, start + 3, in.getChar(start + 1))
- values(index) = name
+ if (index <= 0 || len <= index)
+ errorBadIndex(index)
+
+ values(index) match {
+ case name: Name => name
+ case null =>
+ val start = starts(index)
+ if (in.buf(start).toInt != CONSTANT_UTF8) errorBadTag(start)
+ val name = newTermName(in.buf, start + 3, in.getChar(start + 1))
+ values(index) = name
+ name
}
- name
}
/** Return the name found at given index in the constant pool, with '/' replaced by '.'. */
def getExternalName(index: Int): Name = {
- if (index <= 0 || len <= index) errorBadIndex(index)
- if (internalized(index) eq null) {
+ if (index <= 0 || len <= index)
+ errorBadIndex(index)
+
+ if (internalized(index) == null)
internalized(index) = getName(index).replace('/', '.')
- }
+
internalized(index)
}
@@ -182,10 +187,11 @@ abstract class ClassfileParser {
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
val name = getExternalName(in.getChar(start + 1))
- if (name.endsWith("$"))
- c = definitions.getModule(name.subName(0, name.length - 1))
+ if (name endsWith '$')
+ c = definitions.getModule(name stripEnd "$")
else
c = classNameToSymbol(name)
+
values(index) = c
}
c
@@ -205,7 +211,7 @@ abstract class ClassfileParser {
* - If the member refers to special MODULE$ static field, return
* the symbol of the corresponding module.
* - If the member is a field, and is not found with the given name,
- * another try is made by appending nme.LOCAL_SUFFIX
+ * another try is made by appending nme.LOCAL_SUFFIX_STRING
* - If no symbol is found in the right tpe, a new try is made in the
* companion class, in case the owner is an implementation class.
*/
@@ -242,7 +248,7 @@ abstract class ClassfileParser {
// println("\t" + owner.info.member(name).tpe.widen + " =:= " + tpe)
f = owner.info.member(origName).suchThat(_.tpe.widen =:= tpe)
if (f == NoSymbol)
- f = owner.info.member(newTermName(origName.toString + nme.LOCAL_SUFFIX)).suchThat(_.tpe =:= tpe)
+ f = owner.info.member(newTermName(origName + nme.LOCAL_SUFFIX_STRING)).suchThat(_.tpe =:= tpe)
if (f == NoSymbol) {
// if it's an impl class, try to find it's static member inside the class
if (ownerTpe.typeSymbol.isImplClass) {
@@ -871,10 +877,10 @@ abstract class ClassfileParser {
c convertTo pt
}
def parseAttribute() {
- val attrName = pool.getName(in.nextChar)
+ val attrName = pool.getName(in.nextChar).toTypeName
val attrLen = in.nextInt
attrName match {
- case nme.SignatureATTR =>
+ case tpnme.SignatureATTR =>
if (!isScala && !isScalaRaw) {
val sig = pool.getExternalName(in.nextChar)
val newType = sigToType(sym, sig)
@@ -884,40 +890,40 @@ abstract class ClassfileParser {
hasMeta = true
} else
in.skip(attrLen)
- case nme.SyntheticATTR =>
+ case tpnme.SyntheticATTR =>
sym.setFlag(SYNTHETIC)
in.skip(attrLen)
- case nme.BridgeATTR =>
+ case tpnme.BridgeATTR =>
sym.setFlag(BRIDGE)
in.skip(attrLen)
- case nme.DeprecatedATTR =>
+ case tpnme.DeprecatedATTR =>
val arg = Literal(Constant("see corresponding Javadoc for more information."))
sym.addAnnotation(AnnotationInfo(definitions.DeprecatedAttr.tpe, List(arg), List()))
in.skip(attrLen)
- case nme.ConstantValueATTR =>
+ case tpnme.ConstantValueATTR =>
val c = pool.getConstant(in.nextChar)
val c1 = convertTo(c, symtype)
if (c1 ne null) sym.setInfo(ConstantType(c1))
else println("failure to convert " + c + " to " + symtype); //debug
- case nme.ScalaSignatureATTR =>
+ case tpnme.ScalaSignatureATTR =>
if (!isScalaAnnot) {
if (settings.debug.value)
log("warning: symbol " + sym.fullName + " has pickled signature in attribute")
unpickler.unpickle(in.buf, in.bp, clazz, staticModule, in.file.toString())
}
in.skip(attrLen)
- case nme.ScalaATTR =>
+ case tpnme.ScalaATTR =>
isScalaRaw = true
- case nme.JacoMetaATTR =>
+ case tpnme.JacoMetaATTR =>
val meta = pool.getName(in.nextChar).toString().trim()
metaParser.parse(meta, sym, symtype)
this.hasMeta = true
// Attribute on methods of java annotation classes when that method has a default
- case nme.AnnotationDefaultATTR =>
+ case tpnme.AnnotationDefaultATTR =>
sym.addAnnotation(AnnotationInfo(definitions.AnnotationDefaultAttr.tpe, List(), List()))
in.skip(attrLen)
// Java annotations on classes / methods / fields with RetentionPolicy.RUNTIME
- case nme.RuntimeAnnotationATTR =>
+ case tpnme.RuntimeAnnotationATTR =>
if (isScalaAnnot || !isScala) {
val scalaSigAnnot = parseAnnotations(attrLen)
if (isScalaAnnot)
@@ -935,15 +941,15 @@ abstract class ClassfileParser {
in.skip(attrLen)
// TODO 1: parse runtime visible annotations on parameters
- // case nme.RuntimeParamAnnotationATTR
+ // case tpnme.RuntimeParamAnnotationATTR
// TODO 2: also parse RuntimeInvisibleAnnotation / RuntimeInvisibleParamAnnotation,
// i.e. java annotations with RetentionPolicy.CLASS?
- case nme.ExceptionsATTR if (!isScala) =>
+ case tpnme.ExceptionsATTR if (!isScala) =>
parseExceptions(attrLen)
- case nme.SourceFileATTR =>
+ case tpnme.SourceFileATTR =>
val srcfileLeaf = pool.getName(in.nextChar).toString.trim
val srcpath = sym.enclosingPackage match {
case NoSymbol => srcfileLeaf
@@ -1102,7 +1108,7 @@ abstract class ClassfileParser {
var sflags = transFlags(jflags, true)
val innerClass = getOwner(jflags).newClass(NoPosition, name.toTypeName).setInfo(completer).setFlag(sflags)
- val innerModule = getOwner(jflags).newModule(NoPosition, name).setInfo(completer).setFlag(sflags)
+ val innerModule = getOwner(jflags).newModule(NoPosition, name.toTermName).setInfo(completer).setFlag(sflags)
innerModule.moduleClass.setInfo(global.loaders.moduleClassLoader)
getScope(jflags).enter(innerClass)
@@ -1142,26 +1148,26 @@ abstract class ClassfileParser {
skipMembers() // methods
val attrs = in.nextChar
for (i <- 0 until attrs) {
- val attrName = pool.getName(in.nextChar)
+ val attrName = pool.getName(in.nextChar).toTypeName
val attrLen = in.nextInt
attrName match {
- case nme.SignatureATTR =>
+ case tpnme.SignatureATTR =>
if (!isScala)
hasMeta = true
in.skip(attrLen)
- case nme.JacoMetaATTR =>
+ case tpnme.JacoMetaATTR =>
this.hasMeta = true
in.skip(attrLen)
- case nme.ScalaSignatureATTR =>
+ case tpnme.ScalaSignatureATTR =>
isScala = true
val pbuf = new PickleBuffer(in.buf, in.bp, in.bp + attrLen)
pbuf.readNat; pbuf.readNat;
if (pbuf.readNat == 0) // a scala signature attribute with no entries means that the actual scala signature
isScalaAnnot = true // is in a ScalaSignature annotation.
in.skip(attrLen)
- case nme.ScalaATTR =>
+ case tpnme.ScalaATTR =>
isScalaRaw = true
- case nme.InnerClassesATTR if !isScala =>
+ case tpnme.InnerClassesATTR if !isScala =>
val entries = in.nextChar.toInt
for (i <- 0 until entries) {
val innerIndex = in.nextChar.toInt
@@ -1182,9 +1188,9 @@ abstract class ClassfileParser {
/** An entry in the InnerClasses attribute of this class file. */
case class InnerClassEntry(external: Int, outer: Int, name: Int, jflags: Int) {
- def externalName: Name = pool.getClassName(external)
- def outerName: Name = pool.getClassName(outer)
- def originalName: Name = pool.getName(name)
+ def externalName = pool.getClassName(external)
+ def outerName = pool.getClassName(outer)
+ def originalName = pool.getName(name)
override def toString =
originalName + " in " + outerName + "(" + externalName +")"
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index ecd34d02b0..3d19ceb04f 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -91,11 +91,10 @@ abstract class ICodeReader extends ClassfileParser {
}
private def parseMember(field: Boolean): (Int, Symbol) = {
- val jflags = in.nextChar
- val name = pool.getName(in.nextChar)
-
- val owner = getOwner(jflags)
- val dummySym = owner.newMethod(owner.pos, name).setFlag(javaToScalaFlags(jflags))
+ val jflags = in.nextChar
+ val name = pool.getName(in.nextChar)
+ val owner = getOwner(jflags)
+ val dummySym = owner.newMethod(owner.pos, name) setFlag javaToScalaFlags(jflags)
try {
val ch = in.nextChar
@@ -107,7 +106,7 @@ abstract class ICodeReader extends ClassfileParser {
val owner = getOwner(jflags)
var sym = owner.info.member(name).suchThat(old => sameType(old.tpe, tpe));
if (sym == NoSymbol)
- sym = owner.info.member(newTermName(name.toString + nme.LOCAL_SUFFIX)).suchThat(old => old.tpe =:= tpe);
+ sym = owner.info.member(newTermName(name + nme.LOCAL_SUFFIX_STRING)).suchThat(old => old.tpe =:= tpe);
if (sym == NoSymbol) {
log("Could not find symbol for " + name + ": " + tpe)
log(owner.info.member(name).tpe + " : " + tpe)
@@ -177,10 +176,10 @@ abstract class ICodeReader extends ClassfileParser {
}
def parseAttribute() {
- val attrName = pool.getName(in.nextChar)
+ val attrName = pool.getName(in.nextChar).toTypeName
val attrLen = in.nextInt
attrName match {
- case nme.CodeATTR =>
+ case tpnme.CodeATTR =>
parseByteCode()
case _ =>
in.skip(attrLen)
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
index 7db6e72a6c..246bb6a88d 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala
@@ -133,7 +133,7 @@ abstract class Pickler extends SubComponent {
val children =
if (locals.isEmpty) globals
else {
- val localChildDummy = sym.newClass(sym.pos, nme.LOCALCHILD)
+ val localChildDummy = sym.newClass(sym.pos, tpnme.LOCAL_CHILD)
localChildDummy.setInfo(ClassInfoType(List(sym.tpe), EmptyScope, localChildDummy))
localChildDummy :: globals
}
diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
index 98ae175dad..e3a90fadd3 100644
--- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
@@ -329,7 +329,7 @@ abstract class AddInterfaces extends InfoTransform {
/* !!!
case Super(qual, mix) =>
val mix1 = mix
- if (mix == nme.EMPTY.toTypeName) mix
+ if (mix == tpnme.EMPTY) mix
else {
val ps = atPhase(currentRun.erasurePhase) {
sym.info.parents dropWhile (p => p.symbol.name != mix)
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index 943960c3f7..5955a48499 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -25,6 +25,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
private val newStaticMembers = mutable.Buffer.empty[Tree]
private val newStaticInits = mutable.Buffer.empty[Tree]
private val symbolsStoredAsStatic = mutable.Map.empty[String, Symbol]
+ private def mkTerm(prefix: String): TermName = unit.freshTermName(prefix)
//private val classConstantMeth = new HashMap[String, Symbol]
//private val symbolStaticFields = new HashMap[String, (Symbol, Tree, Tree)]
@@ -91,10 +92,6 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
* refinement, where the refinement defines a parameter based on a
* type variable. */
case ad@ApplyDynamic(qual0, params) =>
- def mkName(s: String = "") =
- if (s == "") unit.fresh.newName()
- else unit.fresh.newName(s)
- def mkTerm(s: String = "") = newTermName(mkName(s))
val typedPos = typedWithPos(ad.pos) _
assert(ad.symbol.isPublic)
@@ -103,7 +100,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
/* ### CREATING THE METHOD CACHE ### */
def addStaticVariableToClass(forName: String, forType: Type, forInit: Tree, isFinal: Boolean): Symbol = {
- val varSym = currentClass.newVariable(ad.pos, mkName(forName))
+ val varSym = currentClass.newVariable(ad.pos, mkTerm(forName))
.setFlag(PRIVATE | STATIC | SYNTHETIC)
.setInfo(forType)
if (isFinal) varSym setFlag FINAL else varSym addAnnotation AnnotationInfo(VolatileAttr.tpe, Nil, Nil)
@@ -120,7 +117,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
def addStaticMethodToClass(forName: String, forArgsTypes: List[Type], forResultType: Type)
(forBody: Pair[Symbol, List[Symbol]] => Tree): Symbol = {
- val methSym = currentClass.newMethod(ad.pos, mkName(forName))
+ val methSym = currentClass.newMethod(ad.pos, mkTerm(forName))
.setFlag(STATIC | SYNTHETIC)
methSym.setInfo(MethodType(methSym.newSyntheticValueParams(forArgsTypes), forResultType))
@@ -387,7 +384,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
def invocation = (lookup DOT invokeName)(qual, invokeArgs) // .invoke(qual, ...)
// exception catching machinery
- val invokeExc = currentOwner.newValue(ad.pos, mkTerm()) setInfo InvocationTargetExceptionClass.tpe
+ val invokeExc = currentOwner.newValue(ad.pos, mkTerm("")) setInfo InvocationTargetExceptionClass.tpe
def catchVar = Bind(invokeExc, Typed(Ident(nme.WILDCARD), TypeTree(InvocationTargetExceptionClass.tpe)))
def catchBody = Throw(Apply(Select(Ident(invokeExc), nme.getCause), Nil))
@@ -431,7 +428,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
if (settings.refinementMethodDispatch.value == "invoke-dynamic") {
/* val guardCallSite: Tree = {
val cachedClass = addStaticVariableToClass("cachedClass", definitions.ClassClass.tpe, EmptyTree)
- val tmpVar = currentOwner.newVariable(ad.pos, unit.fresh.newName(ad.pos, "x")).setInfo(definitions.AnyRefClass.tpe)
+ val tmpVar = currentOwner.newVariable(ad.pos, unit.freshTermName(ad.pos, "x")).setInfo(definitions.AnyRefClass.tpe)
atPos(ad.pos)(Block(List(
ValDef(tmpVar, transform(qual))),
If(Apply(Select(gen.mkAttributedRef(cachedClass), nme.EQ), List(getClass(Ident(tmpVar)))),
@@ -551,7 +548,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
case theTry @ Try(block, catches, finalizer)
if theTry.tpe.typeSymbol != definitions.UnitClass && theTry.tpe.typeSymbol != definitions.NothingClass =>
val tpe = theTry.tpe.widen
- val tempVar = currentOwner.newVariable(theTry.pos, unit.fresh.newName(nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe)
+ val tempVar = currentOwner.newVariable(theTry.pos, mkTerm(nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe)
def assignBlock(rhs: Tree) = super.transform(BLOCK(Ident(tempVar) === transform(rhs)))
val newBlock = assignBlock(block)
@@ -612,11 +609,10 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
*/
private def getSymbolStaticField(pos: Position, symname: String, rhs: Tree, tree: Tree): Symbol =
symbolsStoredAsStatic.getOrElseUpdate(symname, {
- val freshname = unit.fresh.newName("symbol$")
val theTyper = typer.atOwner(tree, currentClass)
// create a symbol for the static field
- val stfieldSym = currentClass.newVariable(pos, freshname)
+ val stfieldSym = currentClass.newVariable(pos, mkTerm("symbol$"))
.setFlag(PRIVATE | STATIC | SYNTHETIC | FINAL)
.setInfo(symbolType)
currentClass.info.decls enter stfieldSym
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index 7a25df6dc3..3607d517ec 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -353,7 +353,7 @@ abstract class ExplicitOuter extends InfoTransform
var nselector = transform(selector)
def makeGuardDef(vs: List[Symbol], guard: Tree) = {
- val gdname = unit.fresh.newName("gd")
+ val gdname = unit.freshTermName("gd")
val method = currentOwner.newMethod(tree.pos, gdname) setFlag SYNTHETIC
val fmls = vs map (_.tpe)
val tpe = new MethodType(method newSyntheticValueParams fmls, BooleanClass.tpe)
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index b32f0ed6bf..a12997226e 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -254,8 +254,10 @@ abstract class LambdaLift extends InfoTransform {
sym.owner.name + "$"
else ""
)
- val fresh = unit.fresh.newName(base)
- sym.name = if (sym.name.isTypeName) fresh.toTypeName else fresh
+ sym.name =
+ if (sym.name.isTypeName) unit.freshTypeName(base)
+ else unit.freshTermName(base)
+
if (settings.debug.value) log("renamed: " + sym.name)
}
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index 5b6f19c18e..c47d1d1d73 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -632,7 +632,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
def completeSuperAccessor(stat: Tree) = stat match {
case DefDef(mods, name, tparams, List(vparams), tpt, EmptyTree)
if (stat.symbol.isSuperAccessor) =>
- val rhs0 = (Super(clazz, nme.EMPTY.toTypeName) DOT stat.symbol.alias)(vparams map (v => Ident(v.symbol)): _*)
+ val rhs0 = (Super(clazz, tpnme.EMPTY) DOT stat.symbol.alias)(vparams map (v => Ident(v.symbol)): _*)
val rhs1 = localTyper.typed(atPos(stat.pos)(rhs0), stat.symbol.tpe.resultType)
val rhs2 = atPhase(currentRun.mixinPhase)(transform(rhs1))
if (settings.debug.value)
@@ -1114,7 +1114,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
// - if `m' refers to a trait, insert a static call to the corresponding static
// implementation
// - otherwise return tree unchanged
- if (mix == nme.EMPTY.toTypeName && currentOwner.enclClass.isImplClass)
+ if (mix == tpnme.EMPTY && currentOwner.enclClass.isImplClass)
assert(false, "illegal super in trait: " + currentOwner.enclClass + " " + tree);
if (sym.owner hasFlag lateINTERFACE) {
if (sym.hasAccessorFlag) {
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 34015ef092..6df4595022 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -210,7 +210,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
* guarantees the same result regardless of the map order by sorting
* type variables alphabetically.
*/
- private def specializedName(sym: Symbol, env: TypeEnv): Name = {
+ private def specializedName(sym: Symbol, env: TypeEnv): TermName = {
val tvars = if (sym.isClass) env.keySet
else specializedTypeVars(sym).intersect(env.keySet)
val (methparams, others) = tvars.toList.partition(_.owner.isMethod)
@@ -223,7 +223,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
/** Specialize name for the two list of types. The first one denotes
* specialization on method type parameters, the second on outer environment.
*/
- private def specializedName(name: Name, types1: List[Type], types2: List[Type]): Name = {
+ private def specializedName(name: Name, types1: List[Type], types2: List[Type]): TermName = {
if (nme.INITIALIZER == name || (types1.isEmpty && types2.isEmpty))
name
else if (nme.isSetterName(name))
@@ -1143,7 +1143,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
case ddef @ DefDef(mods, name, tparams, vparamss, tpt, rhs) if info.isDefinedAt(symbol) =>
if (symbol.isConstructor) {
val t = atOwner(symbol) {
- val superRef: Tree = Select(Super(nme.EMPTY.toTypeName, nme.EMPTY.toTypeName), nme.CONSTRUCTOR)
+ val superRef: Tree = Select(Super(tpnme.EMPTY, tpnme.EMPTY), nme.CONSTRUCTOR)
forwardCtorCall(tree.pos, superRef, vparamss, symbol.owner)
}
if (symbol.isPrimaryConstructor) localTyper typed {
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 0d87ba1203..497450c6c4 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -209,7 +209,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr
/** Return non-local return key for given method */
private def nonLocalReturnKey(meth: Symbol) =
nonLocalReturnKeys.getOrElseUpdate(meth, {
- meth.newValue(meth.pos, unit.fresh.newName("nonLocalReturnKey"))
+ meth.newValue(meth.pos, unit.freshTermName("nonLocalReturnKey"))
.setFlag (SYNTHETIC)
.setInfo (ObjectClass.tpe)
})
@@ -249,7 +249,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr
val pat = Bind(ex,
Typed(Ident(nme.WILDCARD),
AppliedTypeTree(Ident(NonLocalReturnControlClass),
- List(Bind(nme.WILDCARD.toTypeName,
+ List(Bind(tpnme.WILDCARD,
EmptyTree)))))
val rhs =
If(
@@ -503,7 +503,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr
def liftTree(tree: Tree) = {
if (settings.debug.value)
log("lifting tree at: " + (tree.pos))
- val sym = currentOwner.newMethod(tree.pos, unit.fresh.newName("liftedTree"))
+ val sym = currentOwner.newMethod(tree.pos, unit.freshTermName("liftedTree"))
sym.setInfo(MethodType(List(), tree.tpe))
new ChangeOwnerTraverser(currentOwner, sym).traverse(tree)
localTyper.typed {
@@ -676,7 +676,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr
case Try(body, catches, finalizer) =>
if (catches forall treeInfo.isCatchCase) tree
else {
- val exname = unit.fresh.newName("ex$")
+ val exname = unit.freshTermName("ex$")
val cases =
if ((catches exists treeInfo.isDefaultCase) || (catches.last match { // bq: handle try { } catch { ... case ex:Throwable => ...}
case CaseDef(Typed(Ident(nme.WILDCARD), tpt), EmptyTree, _) if (tpt.tpe =:= ThrowableClass.tpe) =>
@@ -702,7 +702,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr
case Apply(Apply(fn, args), args1) =>
treeCopy.Apply(tree, fn, args ::: args1)
case Ident(name) =>
- assert(name != nme.WILDCARD_STAR)
+ assert(name != tpnme.WILDCARD_STAR)
applyUnary()
case Select(_, _) | TypeApply(_, _) =>
applyUnary()
diff --git a/src/compiler/scala/tools/nsc/typechecker/DeVirtualize.scala b/src/compiler/scala/tools/nsc/typechecker/DeVirtualize.scala
index 077cc1d057..64b05d46f3 100644
--- a/src/compiler/scala/tools/nsc/typechecker/DeVirtualize.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/DeVirtualize.scala
@@ -463,7 +463,7 @@ abstract class DeVirtualize extends InfoTransform with TypingTransformers {
val bridge = meth.cloneSymbol(cclazz)
.resetFlag(notOVERRIDE | notFINAL)
cclazz.info.decls.enter(bridge)
- val superRef: Tree = Select(Super(cclazz, nme.EMPTY.toTypeName), meth)
+ val superRef: Tree = Select(Super(cclazz, tpnme.EMPTY), meth)
DefDef(bridge, gen.mkForwarder(superRef, bridge.paramss))
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
index c24d5c0505..df3a82defd 100644
--- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
@@ -52,7 +52,7 @@ trait EtaExpansion { self: Analyzer =>
var cnt = 0 // for NoPosition
def freshName() = {
cnt += 1
- newTermName(unit.fresh.newName("eta$" + (cnt - 1) + "$"))
+ unit.freshTermName("eta$" + (cnt - 1) + "$")
}
val defs = new ListBuffer[Tree]
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index eb775f2301..8de11943cf 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -711,9 +711,9 @@ self: Analyzer =>
tp match {
case TypeRef(pre, sym, args) =>
if (sym.isClass) {
- if (!((sym.name == nme.REFINE_CLASS_NAME.toTypeName) ||
- (sym.name startsWith nme.ANON_CLASS_NAME) ||
- (sym.name == nme.ROOT.toTypeName)))
+ if (!((sym.name == tpnme.REFINE_CLASS_NAME) ||
+ (sym.name startsWith tpnme.ANON_CLASS_NAME) ||
+ (sym.name == tpnme.ROOT)))
partMap get sym match {
case Some(pre1) =>
if (!(pre =:= pre1)) partMap(sym) = NoType // ambiguous prefix - ignore implicit members
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index 4ced09795f..3ffe25c61c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -181,7 +181,7 @@ trait Infer {
tp1 // @MAT aliases already handled by subtyping
}
- private val stdErrorClass = RootClass.newErrorClass(nme.ERROR.toTypeName)
+ private val stdErrorClass = RootClass.newErrorClass(tpnme.ERROR)
private val stdErrorValue = stdErrorClass.newErrorValue(nme.ERROR)
/** The context-dependent inferencer part */
@@ -1309,7 +1309,7 @@ trait Infer {
def isLocalBinding(sym: Symbol) =
sym.isAbstractType &&
((bound contains sym) ||
- sym.name == nme.WILDCARD.toTypeName || {
+ sym.name == tpnme.WILDCARD || {
val e = context.scope.lookupEntry(sym.name)
(e ne null) && e.sym == sym && e.owner == context.scope
})
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 0d614af3ac..e1a8daf6c8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1206,7 +1206,7 @@ trait Namers { self: Analyzer =>
if (currentRun.compileSourceFor(expr, from))
return typeSig(tree)
// for Java code importing Scala objects
- if (from.endsWith(nme.DOLLARraw))
+ if (from.endsWith(nme.raw.DOLLAR))
isValidSelector(from.subName(0, from.length -1)) {
context.error(tree.pos, from.decode + " is not a member of " + expr)
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 9ad7776898..09544e6ab4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -148,7 +148,7 @@ trait NamesDefaults { self: Analyzer =>
// never used for constructor calls, they always have a stable qualifier
def blockWithQualifier(qual: Tree, selected: Name) = {
- val sym = blockTyper.context.owner.newValue(qual.pos, unit.fresh.newName("qual$"))
+ val sym = blockTyper.context.owner.newValue(qual.pos, unit.freshTermName("qual$"))
.setInfo(qual.tpe)
blockTyper.context.scope.enter(sym)
val vd = atPos(sym.pos)(ValDef(sym, qual).setType(NoType))
@@ -253,32 +253,32 @@ trait NamesDefaults { self: Analyzer =>
val byName = isByNameParamType(tpe)
val (argTpe, repeated) =
if (isScalaRepeatedParamType(tpe)) arg match {
- case Typed(expr, Ident(nme.WILDCARD_STAR)) =>
+ case Typed(expr, Ident(tpnme.WILDCARD_STAR)) =>
(expr.tpe, true)
case _ =>
(seqType(arg.tpe), true)
} else (arg.tpe, false)
- val s = context.owner.newValue(arg.pos, unit.fresh.newName("x$"))
+ val s = context.owner.newValue(arg.pos, unit.freshTermName("x$"))
val valType = if (byName) functionType(List(), argTpe)
else if (repeated) argTpe
else argTpe
s.setInfo(valType)
(context.scope.enter(s), byName, repeated)
})
- (symPs, args).zipped map ((symP, arg) => {
- val (sym, byName, repeated) = symP
- // resetAttrs required for #2290. given a block { val x = 1; x }, when wrapping into a function
- // () => { val x = 1; x }, the owner of symbol x must change (to the apply method of the function).
- val body = if (byName) blockTyper.typed(Function(List(), resetLocalAttrs(arg)))
- else if (repeated) arg match {
- case Typed(expr, Ident(nme.WILDCARD_STAR)) =>
- expr
- case _ =>
- val factory = Select(gen.mkAttributedRef(SeqModule), nme.apply)
- blockTyper.typed(Apply(factory, List(resetLocalAttrs(arg))))
- } else arg
- atPos(body.pos)(ValDef(sym, body).setType(NoType))
- })
+ (symPs, args).zipped map {
+ case ((sym, byName, repeated), arg) =>
+ // resetAttrs required for #2290. given a block { val x = 1; x }, when wrapping into a function
+ // () => { val x = 1; x }, the owner of symbol x must change (to the apply method of the function).
+ val body = if (byName) blockTyper.typed(Function(List(), resetLocalAttrs(arg)))
+ else if (repeated) arg match {
+ case Typed(expr, Ident(tpnme.WILDCARD_STAR)) =>
+ expr
+ case _ =>
+ val factory = Select(gen.mkAttributedRef(SeqModule), nme.apply)
+ blockTyper.typed(Apply(factory, List(resetLocalAttrs(arg))))
+ } else arg
+ atPos(body.pos)(ValDef(sym, body).setType(NoType))
+ }
}
// begin transform
@@ -315,7 +315,7 @@ trait NamesDefaults { self: Analyzer =>
atPos(vDef.pos.focus) {
// for by-name parameters, the local value is a nullary function returning the argument
if (isByNameParamType(tpe)) Apply(ref, List())
- else if (isScalaRepeatedParamType(tpe)) Typed(ref, Ident(nme.WILDCARD_STAR))
+ else if (isScalaRepeatedParamType(tpe)) Typed(ref, Ident(tpnme.WILDCARD_STAR))
else ref
}
})
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 1e45ce72e7..5c8e474d58 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -993,11 +993,14 @@ abstract class RefChecks extends InfoTransform {
tree match {
case ModuleDef(mods, name, impl) =>
val sym = tree.symbol
- if (sym.isStatic) {
- val cdef = ClassDef(mods | MODULE, name, List(), impl)
+ def mkClassDef(transformedInfo: Boolean) = {
+ ClassDef(mods | MODULE, name.toTypeName, Nil, impl)
.setPos(tree.pos)
- .setSymbol(sym.moduleClass)
+ .setSymbol(if (transformedInfo) sym.lazyAccessor else sym.moduleClass)
.setType(NoType)
+ }
+ if (sym.isStatic) {
+ val cdef = mkClassDef(false)
if (!sym.allOverriddenSymbols.isEmpty) {
val factory = sym.owner.newMethod(sym.pos, sym.name)
@@ -1020,11 +1023,7 @@ abstract class RefChecks extends InfoTransform {
// that the object info was already run through the transformInfo.
// Since we do not want to have duplicate lazy accessors
// (through duplicate nested object -> lazy val transformation) we have this check here.
- val cdef = ClassDef(mods | MODULE, name, List(), impl)
- .setPos(tree.pos)
- .setSymbol(if (!transformedInfo) sym.moduleClass else sym.lazyAccessor)
- .setType(NoType)
-
+ val cdef = mkClassDef(transformedInfo)
val vdef = localTyper.typedPos(tree.pos){
if (!transformedInfo)
gen.mkModuleVarDef(sym)
@@ -1128,7 +1127,7 @@ abstract class RefChecks extends InfoTransform {
(args corresponds clazz.primaryConstructor.tpe.asSeenFrom(seltpe, clazz).paramTypes)(isIrrefutable) // @PP: corresponds
case Typed(pat, tpt) =>
seltpe <:< tpt.tpe
- case Ident(nme.WILDCARD) =>
+ case Ident(tpnme.WILDCARD) =>
true
case Bind(_, pat) =>
isIrrefutable(pat, seltpe)
@@ -1297,7 +1296,7 @@ abstract class RefChecks extends InfoTransform {
def checkSuper(mix: Name) =
// term should have been eliminated by super accessors
- assert(!(qual.symbol.isTrait && sym.isTerm && mix == nme.EMPTY.toTypeName))
+ assert(!(qual.symbol.isTrait && sym.isTerm && mix == tpnme.EMPTY))
transformCaseApply(tree,
qual match {
@@ -1387,15 +1386,15 @@ abstract class RefChecks extends InfoTransform {
enterReference(tree.pos, tpt.tpe.typeSymbol)
tree
- case Typed(_, Ident(nme.WILDCARD_STAR)) if !isRepeatedParamArg(tree) =>
+ case Typed(_, Ident(tpnme.WILDCARD_STAR)) if !isRepeatedParamArg(tree) =>
unit.error(tree.pos, "no `: _*' annotation allowed here\n"+
"(such annotations are only allowed in arguments to *-parameters)")
tree
case Ident(name) =>
transformCaseApply(tree,
- if (name != nme.WILDCARD && name != nme.WILDCARD_STAR) {
- assert(sym != NoSymbol, tree) //debug
+ if (name != nme.WILDCARD && name != tpnme.WILDCARD_STAR) {
+ assert(sym != NoSymbol, "transformCaseApply: name = " + name.debugString + " tree = " + tree + " / " + tree.getClass) //debug
enterReference(tree.pos, sym)
}
)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
index 023d159d07..09a0f4cfe4 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala
@@ -87,12 +87,12 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
if (sym.isDeferred) {
val member = sym.overridingSymbol(clazz);
- if (mix != nme.EMPTY.toTypeName || member == NoSymbol ||
+ if (mix != tpnme.EMPTY || member == NoSymbol ||
!((member hasFlag ABSOVERRIDE) && member.isIncompleteIn(clazz)))
unit.error(tree.pos, ""+sym+sym.locationString+" is accessed from super. It may not be abstract "+
"unless it is overridden by a member declared `abstract' and `override'");
}
- if (tree.isTerm && mix == nme.EMPTY.toTypeName &&
+ if (tree.isTerm && mix == tpnme.EMPTY &&
(clazz.isTrait || clazz != currentOwner.enclClass || !validCurrentOwner)) {
val supername = nme.superName(sym.name)
var superAcc = clazz.info.decl(supername).suchThat(_.alias == sym)
@@ -191,7 +191,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT
if (sym.isParamAccessor && sym.alias != NoSymbol) {
val result = localTyper.typed {
Select(
- Super(qual.symbol, nme.EMPTY.toTypeName/*qual.symbol.info.parents.head.symbol.name*/) setPos qual.pos,
+ Super(qual.symbol, tpnme.EMPTY/*qual.symbol.info.parents.head.symbol.name*/) setPos qual.pos,
sym.alias) setPos tree.pos
}
if (settings.debug.value)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 1c8414671c..a1f152c39c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -182,7 +182,7 @@ trait SyntheticMethods extends ast.TreeDSL {
// returns (Apply, Bind)
def makeTrees(acc: Symbol, cpt: Type): (Tree, Bind) = {
- val varName = context.unit.fresh.newName(acc.name + "$")
+ val varName = context.unit.freshTermName(acc.name + "$")
val isRepeated = isRepeatedParamType(cpt)
val binding = if (isRepeated) Star(WILD()) else WILD()
val eqMethod: Tree =
@@ -221,7 +221,7 @@ trait SyntheticMethods extends ast.TreeDSL {
def newAccessorMethod(tree: Tree): Tree = tree match {
case DefDef(_, _, _, _, _, rhs) =>
var newAcc = tree.symbol.cloneSymbol
- newAcc.name = context.unit.fresh.newName(tree.symbol.name + "$")
+ newAcc.name = context.unit.freshTermName(tree.symbol.name + "$")
newAcc setFlag SYNTHETIC resetFlag (ACCESSOR | PARAMACCESSOR | PRIVATE | PROTECTED)
newAcc.privateWithin = NoSymbol
newAcc = newAcc.owner.info.decls enter newAcc
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index b6e45fe58c..a36ba92c88 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3051,7 +3051,7 @@ trait Typers { self: Analyzer =>
def typedBind(name: Name, body: Tree) = {
var vble = tree.symbol
if (name.isTypeName) {
- assert(body == EmptyTree)
+ assert(body == EmptyTree, context.unit + " typedBind: " + name.debugString + " " + body + " " + body.getClass)
if (vble == NoSymbol)
vble =
if (isFullyDefined(pt))
@@ -3060,7 +3060,7 @@ trait Typers { self: Analyzer =>
context.owner.newAbstractType(tree.pos, name) setInfo
TypeBounds(NothingClass.tpe, AnyClass.tpe)
val rawInfo = vble.rawInfo
- vble = if (vble.name == nme.WILDCARD.toTypeName) context.scope.enter(vble)
+ vble = if (vble.name == tpnme.WILDCARD) context.scope.enter(vble)
else namer.enterInScope(vble)
tree setSymbol vble setType vble.tpe
} else {
@@ -3899,7 +3899,7 @@ trait Typers { self: Analyzer =>
val params = for (i <- List.range(0, arity)) yield
atPos(tree.pos.focusStart) {
ValDef(Modifiers(PARAM | SYNTHETIC),
- unit.fresh.newName("x" + i + "$"), TypeTree(), EmptyTree)
+ unit.freshTermName("x" + i + "$"), TypeTree(), EmptyTree)
}
val ids = for (p <- params) yield Ident(p.name)
val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) }
@@ -3940,7 +3940,7 @@ trait Typers { self: Analyzer =>
case Typed(expr, Function(List(), EmptyTree)) =>
typedEta(checkDead(typed1(expr, mode, pt)))
- case Typed(expr, tpt @ Ident(nme.WILDCARD_STAR)) =>
+ case Typed(expr, tpt @ Ident(tpnme.WILDCARD_STAR)) =>
val expr0 = typed(expr, mode & stickyModes, WildcardType)
def subArrayType(pt: Type) =
if (isValueClass(pt.typeSymbol) || !isFullyDefined(pt)) arrayType(pt)
@@ -4077,7 +4077,7 @@ trait Typers { self: Analyzer =>
case Ident(name) =>
incCounter(typedIdentCount)
if ((name == nme.WILDCARD && (mode & (PATTERNmode | FUNmode)) == PATTERNmode) ||
- (name == nme.WILDCARD.toTypeName && (mode & TYPEmode) != 0))
+ (name == tpnme.WILDCARD && (mode & TYPEmode) != 0))
tree setType makeFullyDefined(pt)
else
typedIdent(name)
diff --git a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
index cf6994da51..c3e242de03 100644
--- a/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
+++ b/src/compiler/scala/tools/nsc/util/FreshNameCreator.scala
@@ -24,7 +24,7 @@ trait FreshNameCreator {
object FreshNameCreator {
class Default extends FreshNameCreator {
protected var counter = 0
- protected val counters = new HashMap[String, Int]
+ protected val counters = new HashMap[String, Int] withDefaultValue 0
/**
* Create a fresh name with the given prefix. It is guaranteed
@@ -32,10 +32,10 @@ object FreshNameCreator {
* call to this function (provided the prefix does not end in a digit).
*/
def newName(prefix: String): String = {
- val safePrefix = prefix.replace('<', '$').replace('>', '$')
- val count = counters.getOrElse(safePrefix, 0) + 1
- counters(safePrefix) = count
- safePrefix + count
+ val safePrefix = prefix.replaceAll("""[<>]""", """\$""")
+ counters(safePrefix) += 1
+
+ safePrefix + counters(safePrefix)
}
def newName(): String = {
counter += 1
diff --git a/src/library/scala/reflect/generic/Names.scala b/src/library/scala/reflect/generic/Names.scala
index 1b31726e3a..8ec05684d1 100755
--- a/src/library/scala/reflect/generic/Names.scala
+++ b/src/library/scala/reflect/generic/Names.scala
@@ -2,20 +2,39 @@ package scala.reflect
package generic
trait Names {
-
type Name >: Null <: AnyRef
-
- def newTermName(cs: Array[Char], offset: Int, len: Int): Name
- def newTermName(cs: Array[Byte], offset: Int, len: Int): Name
- def newTermName(s: String): Name
-
- def mkTermName(name: Name): Name
-
- def newTypeName(cs: Array[Char], offset: Int, len: Int): Name
- def newTypeName(cs: Array[Byte], offset: Int, len: Int): Name
- def newTypeName(s: String): Name
-
- def mkTypeName(name: Name): Name
+ type TypeName <: Name
+ type TermName <: Name
+
+ def newTermName(cs: Array[Char], offset: Int, len: Int): TermName
+ def newTermName(cs: Array[Byte], offset: Int, len: Int): TermName
+ def newTermName(s: String): TermName
+ def mkTermName(name: Name): TermName
+
+ def newTypeName(cs: Array[Char], offset: Int, len: Int): TypeName
+ def newTypeName(cs: Array[Byte], offset: Int, len: Int): TypeName
+ def newTypeName(s: String): TypeName
+ def mkTypeName(name: Name): TypeName
+
+ def isTermName(name: Name): Boolean
+ def isTypeName(name: Name): Boolean
+
+ /** These should come out before 2.9 ships, but they have to be
+ * in the library to reach a few bits like the unpickler.
+ */
+ def onNameTranslate(name: Name): Unit = ()
+ implicit def promoteTypeNamesAsNecessary(name: Name): TypeName = {
+ if (isTermName(name))
+ onNameTranslate(name)
+
+ mkTypeName(name)
+ }
+ implicit def promoteTermNamesAsNecessary(name: Name): TermName = {
+ if (isTypeName(name))
+ onNameTranslate(name)
+
+ mkTermName(name)
+ }
}
diff --git a/src/library/scala/reflect/generic/StdNames.scala b/src/library/scala/reflect/generic/StdNames.scala
index 7d2e0fde6a..f0fb790a5e 100755
--- a/src/library/scala/reflect/generic/StdNames.scala
+++ b/src/library/scala/reflect/generic/StdNames.scala
@@ -3,33 +3,48 @@ package generic
import scala.reflect.NameTransformer
-trait StdNames { self: Universe =>
+trait LowPriorityStdNames {
+ self: Universe =>
- val nme: StandardNames
+ implicit def stringToTypeName(s: String): TypeName = newTypeName(s)
+}
- def encode(str: String): Name = newTermName(NameTransformer.encode(str))
+trait StdNames extends LowPriorityStdNames {
+ self: Universe =>
- class StandardNames {
- val EXPAND_SEPARATOR_STRING = "$$"
- val LOCAL_SUFFIX_STRING = " "
+ val nme: LibraryTermNames
+ val tpnme: LibraryTypeNames
+
+ def encode(str: String): TermName = newTermName(NameTransformer.encode(str))
+
+ implicit def stringToTermName(s: String): TermName = newTermName(s)
- val EMPTY = newTermName("")
- val EMPTY_PACKAGE_NAME = newTermName("<empty>")
- val IMPORT = newTermName("<import>")
- val REFINE_CLASS_NAME = newTermName("<refinement>")
- val ROOT = newTermName("<root>")
+ trait LibraryCommonNames {
+ type NameType <: Name
+ implicit def createNameType(name: String): NameType
- val ANON_CLASS_NAME = newTermName("$anon")
- val ANON_FUN_NAME = newTermName("$anonfun")
- val MODULE_SUFFIX = newTermName("$module")
- val ROOTPKG = newTermName("_root_")
+ val EMPTY: NameType = ""
+ val ANON_FUN_NAME: NameType = "$anonfun"
+ val EMPTY_PACKAGE_NAME: NameType = "<empty>"
+ val IMPORT: NameType = "<import>"
+ val MODULE_SUFFIX: NameType = "$module"
+ val ROOT: NameType = "<root>"
+ val ROOTPKG: NameType = "_root_"
+ }
+
+ trait LibraryTermNames extends LibraryCommonNames {
+ val EXPAND_SEPARATOR_STRING = "$$"
+ val LOCAL_SUFFIX_STRING = " "
/** The expanded name of `name' relative to this class `base` with given `separator`
*/
- def expandedName(name: Name, base: Symbol, separator: String = EXPAND_SEPARATOR_STRING): Name =
+ def expandedName(name: TermName, base: Symbol, separator: String = EXPAND_SEPARATOR_STRING): TermName =
newTermName(base.fullName('$') + separator + name)
- def moduleVarName(name: Name): Name =
- newTermName(name.toString + MODULE_SUFFIX)
+ def moduleVarName(name: TermName): TermName = newTermName("" + name + MODULE_SUFFIX)
+ }
+ trait LibraryTypeNames extends LibraryCommonNames {
+ val REFINE_CLASS_NAME: NameType = "<refinement>"
+ val ANON_CLASS_NAME: NameType = "$anon"
}
}
diff --git a/src/library/scala/reflect/generic/Symbols.scala b/src/library/scala/reflect/generic/Symbols.scala
index 4dcf80efe3..1e6112eebb 100755
--- a/src/library/scala/reflect/generic/Symbols.scala
+++ b/src/library/scala/reflect/generic/Symbols.scala
@@ -142,13 +142,13 @@ trait Symbols { self: Universe =>
final def isModule = isTerm && hasFlag(MODULE)
final def isModuleClass = isClass && hasFlag(MODULE)
final def isOverloaded = hasFlag(OVERLOADED)
- final def isRefinementClass = isClass && name == mkTypeName(nme.REFINE_CLASS_NAME)
+ final def isRefinementClass = isClass && name == tpnme.REFINE_CLASS_NAME
final def isSourceMethod = isMethod && !hasFlag(STABLE) // exclude all accessors!!!
final def isTypeParameter = isType && isParameter && !isSkolem
/** Package tests */
final def isEmptyPackage = isPackage && name == nme.EMPTY_PACKAGE_NAME
- final def isEmptyPackageClass = isPackageClass && name == mkTypeName(nme.EMPTY_PACKAGE_NAME)
+ final def isEmptyPackageClass = isPackageClass && name == tpnme.EMPTY_PACKAGE_NAME
final def isPackage = isModule && hasFlag(PACKAGE)
final def isPackageClass = isClass && hasFlag(PACKAGE)
final def isRoot = isPackageClass && owner == NoSymbol
@@ -160,13 +160,13 @@ trait Symbols { self: Universe =>
// creators
- def newAbstractType(name: Name, pos: Position = NoPosition): Symbol
- def newAliasType(name: Name, pos: Position = NoPosition): Symbol
- def newClass(name: Name, pos: Position = NoPosition): Symbol
- def newMethod(name: Name, pos: Position = NoPosition): Symbol
- def newModule(name: Name, clazz: Symbol, pos: Position = NoPosition): Symbol
- def newModuleClass(name: Name, pos: Position = NoPosition): Symbol
- def newValue(name: Name, pos: Position = NoPosition): Symbol
+ def newAbstractType(name: TypeName, pos: Position = NoPosition): Symbol
+ def newAliasType(name: TypeName, pos: Position = NoPosition): Symbol
+ def newClass(name: TypeName, pos: Position = NoPosition): Symbol
+ def newMethod(name: TermName, pos: Position = NoPosition): Symbol
+ def newModule(name: TermName, clazz: Symbol, pos: Position = NoPosition): Symbol
+ def newModuleClass(name: TypeName, pos: Position = NoPosition): Symbol
+ def newValue(name: TermName, pos: Position = NoPosition): Symbol
// access to related symbols
diff --git a/src/library/scala/reflect/generic/Trees.scala b/src/library/scala/reflect/generic/Trees.scala
index 7ab4cf882b..2573b6b191 100755
--- a/src/library/scala/reflect/generic/Trees.scala
+++ b/src/library/scala/reflect/generic/Trees.scala
@@ -18,7 +18,7 @@ trait Trees { self: Universe =>
protected def flagsIntoString(flags: Long, privateWithin: String): String
/** @param privateWithin the qualifier for a private (a type name)
- * or nme.EMPTY.toTypeName, if none is given.
+ * or tpnme.EMPTY, if none is given.
* @param annotations the annotations for the definition.
* <strong>Note:</strong> the typechecker drops these annotations,
* use the AnnotationInfo's (Symbol.annotations) in later phases.
@@ -29,9 +29,7 @@ trait Trees { self: Universe =>
type AccessBoundaryType = Name
type AnnotationType = Tree
- private val emptyTypeName = mkTypeName(nme.EMPTY)
-
- def hasAccessBoundary = privateWithin != emptyTypeName
+ def hasAccessBoundary = privateWithin != tpnme.EMPTY
def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask
def hasFlag(flag: Long) = (flag & flags) != 0L
def hasFlagsToString(mask: Long): String = flagsToString(
@@ -63,7 +61,7 @@ trait Trees { self: Universe =>
}
def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List(), Map.empty)
- def Modifiers(flags: Long): Modifiers = Modifiers(flags, mkTypeName(nme.EMPTY))
+ def Modifiers(flags: Long): Modifiers = Modifiers(flags, tpnme.EMPTY)
lazy val NoMods = Modifiers(0)
@@ -204,30 +202,31 @@ trait Trees { self: Universe =>
}
/** Class definition */
- case class ClassDef(mods: Modifiers, name: Name, tparams: List[TypeDef], impl: Template)
+ case class ClassDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], impl: Template)
extends ImplDef
/** Singleton object definition
*/
- case class ModuleDef(mods: Modifiers, name: Name, impl: Template)
+ case class ModuleDef(mods: Modifiers, name: TermName, impl: Template)
extends ImplDef
abstract class ValOrDefDef extends MemberDef {
+ def name: TermName
def tpt: Tree
def rhs: Tree
}
/** Value definition
*/
- case class ValDef(mods: Modifiers, name: Name, tpt: Tree, rhs: Tree) extends ValOrDefDef
+ case class ValDef(mods: Modifiers, name: TermName, tpt: Tree, rhs: Tree) extends ValOrDefDef
/** Method definition
*/
- case class DefDef(mods: Modifiers, name: Name, tparams: List[TypeDef],
+ case class DefDef(mods: Modifiers, name: TermName, tparams: List[TypeDef],
vparamss: List[List[ValDef]], tpt: Tree, rhs: Tree) extends ValOrDefDef
/** Abstract type, type parameter, or type alias */
- case class TypeDef(mods: Modifiers, name: Name, tparams: List[TypeDef], rhs: Tree)
+ case class TypeDef(mods: Modifiers, name: TypeName, tparams: List[TypeDef], rhs: Tree)
extends MemberDef
/** <p>
@@ -247,7 +246,7 @@ trait Trees { self: Universe =>
* jumps within a Block.
* </p>
*/
- case class LabelDef(name: Name, params: List[Ident], rhs: Tree)
+ case class LabelDef(name: TermName, params: List[Ident], rhs: Tree)
extends DefTree with TermTree
@@ -415,13 +414,13 @@ trait Trees { self: Universe =>
// The symbol of an ApplyDynamic is the function symbol of `qual', or NoSymbol, if there is none.
/** Super reference */
- case class Super(qual: Name, mix: Name)
+ case class Super(qual: TypeName, mix: TypeName)
extends TermTree with SymTree
// The symbol of a Super is the class _from_ which the super reference is made.
// For instance in C.super(...), it would be C.
/** Self reference */
- case class This(qual: Name)
+ case class This(qual: TypeName)
extends TermTree with SymTree
// The symbol of a This is the class to which the this refers.
// For instance in C.this, it would be C.
@@ -431,8 +430,7 @@ trait Trees { self: Universe =>
extends RefTree
/** Identifier <name> */
- case class Ident(name: Name)
- extends RefTree
+ case class Ident(name: Name) extends RefTree { }
class BackQuotedIdent(name: Name) extends Ident(name)
@@ -604,7 +602,7 @@ trait Trees { self: Universe =>
extends TypTree
/** Type selection <qualifier> # <name>, eliminated by RefCheck */
- case class SelectFromTypeTree(qualifier: Tree, name: Name)
+ case class SelectFromTypeTree(qualifier: Tree, name: TypeName)
extends TypTree with RefTree
/** Intersection type <parent1> with ... with <parentN> { <decls> }, eliminated by RefCheck */
@@ -706,7 +704,7 @@ trait Trees { self: Universe =>
case ApplyDynamic(qual, args) (introduced by erasure, eliminated by cleanup)
// fun(args)
case Super(qual, mix) =>
- // qual.super[mix] if qual and/or mix is empty, ther are nme.EMPTY.toTypeName
+ // qual.super[mix] if qual and/or mix is empty, ther are tpnme.EMPTY
case This(qual) =>
// qual.this
case Select(qualifier, selector) =>
diff --git a/src/library/scala/reflect/generic/UnPickler.scala b/src/library/scala/reflect/generic/UnPickler.scala
index 8a370e44fa..ed103a3a43 100755
--- a/src/library/scala/reflect/generic/UnPickler.scala
+++ b/src/library/scala/reflect/generic/UnPickler.scala
@@ -133,7 +133,7 @@ abstract class UnPickler {
assert(tag == CLASSsym)
readNat(); // read length
- val result = readNameRef() == mkTypeName(nme.REFINE_CLASS_NAME)
+ val result = readNameRef() == tpnme.REFINE_CLASS_NAME
readIndex = savedIndex
result
}
diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
index 915087a256..287a974794 100644
--- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
+++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ScalaSigPrinter.scala
@@ -120,7 +120,7 @@ class ScalaSigPrinter(stream: PrintStream, printPrivates: Boolean) {
private def refinementClass(c: ClassSymbol) = c.name == "<refinement>"
def printClass(level: Int, c: ClassSymbol) {
- if (c.name == "<local child>" /*scala.tools.nsc.symtab.StdNames.LOCALCHILD.toString()*/ ) {
+ if (c.name == "<local child>" /*scala.tools.nsc.symtab.StdNames.LOCAL_CHILD.toString()*/ ) {
print("\n")
} else {
printModifiers(c)
diff --git a/test/files/pos/spec-Function1.scala b/test/files/pos/spec-Function1.scala
index 62789ed12a..ae683b4197 100644
--- a/test/files/pos/spec-Function1.scala
+++ b/test/files/pos/spec-Function1.scala
@@ -1,4 +1,3 @@
-
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2002-2010, LAMP/EPFL **