diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc')
8 files changed, 27 insertions, 31 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala index 4c7083a51f..456e7eae9e 100755 --- a/src/compiler/scala/tools/nsc/ast/DocComments.scala +++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala @@ -495,8 +495,7 @@ trait DocComments { self: Global => val tpe = getType(repl.trim) if (tpe != NoType) tpe else { - val alias1 = alias.cloneSymbol(definitions.RootClass) - alias1.name = newTypeName(repl) + val alias1 = alias.cloneSymbol(definitions.RootClass, alias.rawflags, newTypeName(repl)) typeRef(NoPrefix, alias1, Nil) } case None => diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index 34bad05e1f..e981910bdb 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -66,9 +66,10 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => /** Return the implementation class of a trait; create a new one of one does not yet exist */ def implClass(iface: Symbol): Symbol = { - iface.info def implClassFlags = iface.flags & ~(INTERFACE | lateINTERFACE) | IMPLCLASS + iface.info + implClassMap.getOrElse(iface, { atPhase(implClassPhase) { if (iface.implClass ne NoSymbol) @@ -98,8 +99,7 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure => else log("not unlinking existing " + impl + " as the impl class is not visible on the classpath.") } if (impl == NoSymbol) { - impl = iface.cloneSymbolImpl(iface.owner, implClassFlags) - impl.name = implName + impl = iface.cloneSymbolImpl(iface.owner, implClassFlags) setName implName impl.sourceFile = iface.sourceFile if (iface.owner.isClass) iface.owner.info.decls enter impl diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 13ca8e55bc..36571ceb7f 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -229,10 +229,10 @@ abstract class LambdaLift extends InfoTransform { sym.owner.name + nme.NAME_JOIN_STRING else "" ) - sym.name = + sym setName ( if (sym.name.isTypeName) unit.freshTypeName(base) else unit.freshTermName(base) - + ) debuglog("renaming in %s: %s => %s".format(sym.owner.fullLocationString, originalName, sym.name)) } @@ -241,7 +241,7 @@ abstract class LambdaLift extends InfoTransform { def renameTrait(traitSym: Symbol, implSym: Symbol) { val originalImplName = implSym.name renameSym(traitSym) - implSym.name = nme.implClassName(traitSym.name) + implSym setName nme.implClassName(traitSym.name) debuglog("renaming impl class in step with %s: %s => %s".format(traitSym, originalImplName, implSym.name)) } diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index 1afa1dbf58..51da933312 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -513,8 +513,8 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val sClass = clazz.owner.newClass(clazzName, clazz.pos, (clazz.flags | SPECIALIZED) & ~CASE) - def cloneInSpecializedClass(member: Symbol, flagFn: Long => Long) = - member.cloneSymbol(sClass, flagFn(member.flags | SPECIALIZED)) + def cloneInSpecializedClass(member: Symbol, flagFn: Long => Long, newName: Name = null) = + member.cloneSymbol(sClass, flagFn(member.flags | SPECIALIZED), newName) sClass.sourceFile = clazz.sourceFile currentRun.symSource(sClass) = clazz.sourceFile // needed later on by mixin @@ -726,7 +726,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { else if (m.isClass) { val specClass: Symbol = cloneInSpecializedClass(m, x => x) typeEnv(specClass) = fullEnv - specClass.name = specializedName(specClass, fullEnv).toTypeName + specClass setName specializedName(specClass, fullEnv).toTypeName enterMember(specClass) debuglog("entered specialized class " + specClass.fullName) info(specClass) = SpecializedInnerClass(m, fullEnv) @@ -804,7 +804,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { val env = mapAnyRefsInSpecSym(env0, sym, specMember) val (keys, vals) = env.toList.unzip - specMember.name = specializedName(sym, env) + specMember setName specializedName(sym, env) // debuglog("%s normalizes to %s%s".format(sym, specMember, // if (tps.isEmpty) "" else " with params " + tps.mkString(", "))) @@ -882,10 +882,11 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Return the specialized overload of `m`, in the given environment. */ private def specializedOverload(owner: Symbol, sym: Symbol, env: TypeEnv): Symbol = { + val newFlags = (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | ACCESSOR | LAZY) // this method properly duplicates the symbol's info - val specMember = sym.cloneSymbol(owner, (sym.flags | SPECIALIZED) & ~(DEFERRED | CASEACCESSOR | ACCESSOR | LAZY)) - specMember.name = specializedName(sym, env) - specMember modifyInfo (info => subst(env, info.asSeenFrom(owner.thisType, sym.owner))) + ( sym.cloneSymbol(owner, newFlags, specializedName(sym, env)) + modifyInfo (info => subst(env, info.asSeenFrom(owner.thisType, sym.owner))) + ) } /** For each method m that overrides an inherited method m', add a special diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index a1ba8a2982..9b1f395ad0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -664,7 +664,7 @@ trait Contexts { self: Analyzer => case List(ImportSelector(nme.WILDCARD, _, _, _)) => List(sym) case ImportSelector(from, _, to, _) :: _ if from == sym.name => if (to == nme.WILDCARD) List() - else { val sym1 = sym.cloneSymbol; sym1.name = to; List(sym1) } + else List(sym.cloneSymbol(sym.owner, sym.rawflags, to)) case _ :: rest => transformImport(rest, sym) } diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 04341fea25..82ffc3fd9e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -96,8 +96,7 @@ trait MethodSynthesis { finishMethod(m setInfoAndEnter infoFn(m), f) } private def cloneInternal(original: Symbol, f: Symbol => Tree, name: Name): Tree = { - val m = original.cloneSymbol(clazz, newMethodFlags(original)) setPos clazz.pos.focus - m.name = name + val m = original.cloneSymbol(clazz, newMethodFlags(original), name) setPos clazz.pos.focus finishMethod(clazz.info.decls enter m, f) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index ed17d6efa7..2539091966 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -831,19 +831,17 @@ trait Namers extends MethodSynthesis { if (!hasType) tpt defineType NoType - if (hasType || hasName) { - owner.typeOfThis = - if (hasType) selfTypeCompleter(tpt) - else owner.tpe - } val sym = ( - if (hasType) owner.thisSym setPos self.pos - else if (hasName) owner.thisSym - else owner.newThisSym(self.pos) setInfo owner.tpe + if (hasType || hasName) { + owner.typeOfThis = if (hasType) selfTypeCompleter(tpt) else owner.tpe + val selfSym = owner.thisSym setPos self.pos + if (hasName) selfSym setName name else selfSym + } + else { + val symName = if (name != nme.WILDCARD) name else nme.this_ + owner.newThisSym(symName, owner.pos) setInfo owner.tpe + } ) - if (hasName) - sym.name = name - self.symbol = context.scope enter sym } diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 6efa595d99..3233b7b07c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -270,8 +270,7 @@ trait TypeDiagnostics { private val savedName = sym.name def restoreName() = sym.name = savedName def isAltered = sym.name != savedName - def modifyName(f: String => String) = - sym.name = newTypeName(f(sym.name.toString)) + def modifyName(f: String => String) = sym setName newTypeName(f(sym.name.toString)) /** Prepend java.lang, scala., or Predef. if this type originated * in one of those. |