diff options
author | Martin Odersky <odersky@gmail.com> | 2006-08-18 12:57:21 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-08-18 12:57:21 +0000 |
commit | a2cd7999f5c08aaac52f293d4d0241678ab9c611 (patch) | |
tree | cd9c810d66fc592de6ba551c6c1d671b3488dfe4 | |
parent | e84cda02997bb1b658d1703cefdfcee766812d57 (diff) | |
download | scala-a2cd7999f5c08aaac52f293d4d0241678ab9c611.tar.gz scala-a2cd7999f5c08aaac52f293d4d0241678ab9c611.tar.bz2 scala-a2cd7999f5c08aaac52f293d4d0241678ab9c611.zip |
fixed bug 708.
fixed a problem when no error position was given for an illegal private
qualifier.
4 files changed, 21 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala index 68c1e0d070..cdde98a999 100644 --- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala +++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala @@ -701,6 +701,7 @@ trait Symbols requires SymbolTable { setter(owner).expandName(base) } name = base.expandedName(name) + if (isType) name = name.toTypeName } def expandedName(name: Name): Name = diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index a45e6161b2..15006f7879 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -1021,6 +1021,7 @@ trait Types requires SymbolTable { private def rebind(pre: Type, sym: Symbol): Symbol = { val owner = sym.owner; if (owner.isClass && owner != pre.symbol && !sym.isFinal && !sym.isClass) { + //Console.println("rebind "+pre+" "+sym)//DEBUG val rebind = pre.nonPrivateMember(sym.name).suchThat(sym => sym.isType || sym.isStable); if (rebind == NoSymbol) sym else rebind } else sym diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 74784bb9aa..8089e3079f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -42,9 +42,9 @@ trait Namers requires Analyzer { val typer = newTyper(context); - def setPrivateWithin(sym: Symbol, mods: Modifiers): Symbol = { + def setPrivateWithin(tree: Tree, sym: Symbol, mods: Modifiers): Symbol = { if (!mods.privateWithin.isEmpty) - sym.privateWithin = typer.qualifyingClassContext(EmptyTree, mods.privateWithin).owner; + sym.privateWithin = typer.qualifyingClassContext(tree, mods.privateWithin).owner; sym } @@ -232,15 +232,15 @@ trait Namers requires Analyzer { tree.symbol = enterCaseFactorySymbol( tree.pos, mods.flags & AccessFlags | METHOD | CASE, name.toTermName) .setInfo(innerNamer.caseFactoryCompleter(tree)); - setPrivateWithin(tree.symbol, mods); + setPrivateWithin(tree, tree.symbol, mods); } tree.symbol = enterClassSymbol(tree.pos, mods.flags, name); - setPrivateWithin(tree.symbol, mods); + setPrivateWithin(tree, tree.symbol, mods); finishWith(tparams); case ModuleDef(mods, name, _) => tree.symbol = enterModuleSymbol(tree.pos, mods.flags | MODULE | FINAL, name); - setPrivateWithin(tree.symbol, mods); - setPrivateWithin(tree.symbol.moduleClass, mods); + setPrivateWithin(tree, tree.symbol, mods); + setPrivateWithin(tree, tree.symbol.moduleClass, mods); tree.symbol.moduleClass.setInfo(innerNamer.moduleClassTypeCompleter(tree)); finish case ValDef(mods, name, tp, rhs) => @@ -251,13 +251,13 @@ trait Namers requires Analyzer { val getter = owner.newMethod(tree.pos, name) .setFlag(accflags) .setInfo(innerNamer.getterTypeCompleter(tree)); - setPrivateWithin(getter, mods); + setPrivateWithin(tree, getter, mods); enterInScope(getter); if ((mods.flags & MUTABLE) != 0) { val setter = owner.newMethod(tree.pos, nme.getterToSetter(name)) .setFlag(accflags & ~STABLE & ~CASEACCESSOR) .setInfo(innerNamer.setterTypeCompleter(tree)); - setPrivateWithin(setter, mods); + setPrivateWithin(tree, setter, mods); enterInScope(setter) } tree.symbol = @@ -274,22 +274,22 @@ trait Namers requires Analyzer { case DefDef(mods, nme.CONSTRUCTOR, tparams, _, _, _) => tree.symbol = enterInScope(owner.newConstructor(tree.pos)) .setFlag(mods.flags | owner.getFlag(ConstrFlags)); - setPrivateWithin(tree.symbol, mods); + setPrivateWithin(tree, tree.symbol, mods); finishWith(tparams); case DefDef(mods, name, tparams, _, _, _) => tree.symbol = enterInScope(owner.newMethod(tree.pos, name)) .setFlag(mods.flags); - setPrivateWithin(tree.symbol, mods); + setPrivateWithin(tree, tree.symbol, mods); finishWith(tparams); case AbsTypeDef(mods, name, _, _) => tree.symbol = enterInScope(owner.newAbstractType(tree.pos, name)) .setFlag(mods.flags); - setPrivateWithin(tree.symbol, mods); + setPrivateWithin(tree, tree.symbol, mods); finish case AliasTypeDef(mods, name, tparams, _) => tree.symbol = enterInScope(owner.newAliasType(tree.pos, name)) .setFlag(mods.flags); - setPrivateWithin(tree.symbol, mods); + setPrivateWithin(tree, tree.symbol, mods); finishWith(tparams) case DocDef(_, defn) => enterSym(defn) @@ -365,7 +365,7 @@ trait Namers requires Analyzer { param.symbol = owner.newValueParameter(param.pos, param.name) .setInfo(typeCompleter(param)) .setFlag(param.mods.flags & (BYNAMEPARAM | IMPLICIT)); - setPrivateWithin(param.symbol, param.mods); + setPrivateWithin(param, param.symbol, param.mods); context.scope enter param.symbol; param.symbol } diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 29842d54c9..edd5c8cfd8 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -45,9 +45,13 @@ abstract class SuperAccessors extends transform.Transform { override def transform(tree: Tree): Tree = tree match { case ClassDef(_, _, _, _, _) => - for (val sym <- tree.symbol.info.decls.elements) { - if (sym.privateWithin.isClass && !sym.privateWithin.isModuleClass) + val decls = tree.symbol.info.decls + for (val sym <- decls.toList) { + if (sym.privateWithin.isClass && !sym.privateWithin.isModuleClass) { + decls.unlink(sym) sym.expandName(sym.privateWithin) + decls.enter(sym) + } } super.transform(tree) case Template(parents, body) => |