diff options
Diffstat (limited to 'src/compiler/scala/tools/nsc')
6 files changed, 38 insertions, 53 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index eedc68fb46..b6eef8c0bb 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -465,11 +465,9 @@ abstract class ClassfileParser { } ss = name.subName(0, start) owner.info.decls lookup ss orElse { - sym = owner.newClass(NoPosition, ss.toTypeName) setInfo completer - if (opt.verboseDebug) - println("loaded "+sym+" from file "+file) - - owner.info.decls enter sym + sym = owner.newClass(NoPosition, ss.toTypeName) setInfoAndEnter completer + debuglog("loaded "+sym+" from file "+file) + sym } } diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala index 767b2f1101..3c97122c9c 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala @@ -102,8 +102,7 @@ abstract class ICodeReader extends ClassfileParser { log("Could not find symbol for " + name + ": " + tpe) log(owner.info.member(name).tpe + " : " + tpe) sym = if (field) owner.newValue(name, owner.pos, toScalaFieldFlags(jflags)) else dummySym - sym setInfo tpe - owner.info.decls.enter(sym) + sym setInfoAndEnter tpe log("added " + sym + ": " + sym.tpe) } (jflags, sym) diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala index c59a819b02..8a8131c0f4 100644 --- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala +++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala @@ -247,8 +247,8 @@ abstract class AddInterfaces extends InfoTransform { addMixinConstructorDef(clazz, templ.body map implMemberDef)) .setSymbol(clazz.newLocalDummy(templ.pos)) } - new ChangeOwnerTraverser(templ.symbol.owner, clazz)( - new ChangeOwnerTraverser(templ.symbol, templ1.symbol)(templ1)) + templ1.changeOwner(templ.symbol.owner -> clazz, templ.symbol -> templ1.symbol) + templ1 } def implClassDefs(trees: List[Tree]): List[Tree] = { diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala index 4d4f4f4c27..2b3e5f311f 100644 --- a/src/compiler/scala/tools/nsc/transform/Constructors.scala +++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala @@ -105,8 +105,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { // Move tree into constructor, take care of changing owner from `oldowner` to constructor symbol def intoConstructor(oldowner: Symbol, tree: Tree) = - intoConstructorTransformer.transform( - new ChangeOwnerTraverser(oldowner, constr.symbol)(tree)) + intoConstructorTransformer transform tree.changeOwner(oldowner -> constr.symbol) // Should tree be moved in front of super constructor call? def canBeMoved(tree: Tree) = tree match { @@ -454,28 +453,24 @@ abstract class Constructors extends Transform with ast.TreeDSL { def delayedInitClosure(stats: List[Tree]) = localTyper.typed { atPos(impl.pos) { - val closureClass = clazz.newClass(impl.pos, nme.delayedInitArg.toTypeName) - .setFlag(SYNTHETIC | FINAL) + val closureClass = clazz.newClass(nme.delayedInitArg.toTypeName, impl.pos, SYNTHETIC | FINAL) val closureParents = List(AbstractFunctionClass(0).tpe, ScalaObjectClass.tpe) - closureClass.setInfo(new ClassInfoType(closureParents, new Scope, closureClass)) - - val outerField = closureClass.newValue(impl.pos, nme.OUTER) - .setFlag(PrivateLocal | PARAMACCESSOR) - .setInfo(clazz.tpe) - - val applyMethod = closureClass.newMethod(impl.pos, nme.apply) - .setFlag(FINAL) - .setInfo(MethodType(List(), ObjectClass.tpe)) - - closureClass.info.decls enter outerField - closureClass.info.decls enter applyMethod - - val outerFieldDef = ValDef(outerField) - - val changeOwner = new ChangeOwnerTraverser(impl.symbol, applyMethod) + closureClass setInfoAndEnter new ClassInfoType(closureParents, new Scope, closureClass) + + val outerField = ( + closureClass + newValue(nme.OUTER, impl.pos, PrivateLocal | PARAMACCESSOR) + setInfoAndEnter clazz.tpe + ) + val applyMethod = ( + closureClass + newMethod(nme.apply, impl.pos, FINAL) + setInfoAndEnter MethodType(Nil, ObjectClass.tpe) + ) + val outerFieldDef = ValDef(outerField) val closureClassTyper = localTyper.atOwner(closureClass) - val applyMethodTyper = closureClassTyper.atOwner(applyMethod) + val applyMethodTyper = closureClassTyper.atOwner(applyMethod) val constrStatTransformer = new Transformer { override def transform(tree: Tree): Tree = tree match { @@ -507,8 +502,7 @@ abstract class Constructors extends Transform with ast.TreeDSL { } else tree case _ => - changeOwner.changeOwner(tree) - tree + tree.changeOwner(impl.symbol -> applyMethod) } } } diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala index 2180fd4f3a..0f11161914 100644 --- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala +++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala @@ -213,17 +213,14 @@ abstract class LambdaLift extends InfoTransform { atPhase(phase.next) { for ((owner, freeValues) <- free.toList) { + val newFlags = SYNTHETIC | ( if (owner.isClass) PARAMACCESSOR | PrivateLocal else PARAM ) debuglog("free var proxy: %s, %s".format(owner.fullLocationString, freeValues.toList.mkString(", "))) - - proxies(owner) = - for (fv <- freeValues.toList) yield { - val proxy = owner.newValue(owner.pos, fv.name) - .setFlag(if (owner.isClass) PARAMACCESSOR | PrivateLocal else PARAM) - .setFlag(SYNTHETIC) - .setInfo(fv.info); - if (owner.isClass) owner.info.decls enter proxy; - proxy - } + proxies(owner) = + for (fv <- freeValues.toList) yield { + val proxy = owner.newValue(fv.name, owner.pos, newFlags) setInfo fv.info + if (owner.isClass) owner.info.decls enter proxy + proxy + } } } } @@ -409,12 +406,12 @@ abstract class LambdaLift extends InfoTransform { } else tree1 case Block(stats, expr0) => - val (lzyVals, rest) = stats.partition { - case stat@ValDef(_, _, _, _) if stat.symbol.isLazy => true - case stat@ValDef(_, _, _, _) if stat.symbol.hasFlag(MODULEVAR) => true - case _ => false - } - treeCopy.Block(tree, lzyVals:::rest, expr0) + val (lzyVals, rest) = stats partition { + case stat: ValDef => stat.symbol.isLazy || stat.symbol.isModuleVar + case _ => false + } + if (lzyVals.isEmpty) tree + else treeCopy.Block(tree, lzyVals ::: rest, expr0) case _ => tree } diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 78b3446157..4c14031da3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1166,12 +1166,9 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } def createStaticModuleAccessor() = atPhase(phase.next) { val method = ( - sym.owner.newMethod(sym.pos, sym.name.toTermName) - setFlag (sym.flags | STABLE) - resetFlag MODULE - setInfo NullaryMethodType(sym.moduleClass.tpe) + sym.owner.newMethod(sym.name.toTermName, sym.pos, (sym.flags | STABLE) & ~MODULE) + setInfoAndEnter NullaryMethodType(sym.moduleClass.tpe) ) - sym.owner.info.decls enter method localTyper.typedPos(tree.pos)(gen.mkModuleAccessDef(method, sym)) } def createInnerModuleAccessor(vdef: Tree) = List( |