diff options
author | Martin Odersky <odersky@gmail.com> | 2017-02-02 09:23:56 +1100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-02-02 09:23:56 +1100 |
commit | 157c8dc72def0d452ef6322aaddeac023507d648 (patch) | |
tree | dd1ace9b758f7a126b9b2909f5b2bc7215f09741 /compiler/src | |
parent | c1a37e13befe5a57ff2452e3a3470b1e0d8adb54 (diff) | |
download | dotty-157c8dc72def0d452ef6322aaddeac023507d648.tar.gz dotty-157c8dc72def0d452ef6322aaddeac023507d648.tar.bz2 dotty-157c8dc72def0d452ef6322aaddeac023507d648.zip |
Refactoring to make Checking not mutate denotations
avoidPrivateLeaks got moved from Checking to TypeAssigner, where it
fits well besides the other avoid methods.
Diffstat (limited to 'compiler/src')
4 files changed, 12 insertions, 9 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index dad433c4e..835ed47c1 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -733,7 +733,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table, posUnpickle // no longer necessary. goto(end) setPos(start, tree) - Checking.avoidPrivateLeaks(sym, tree.pos) + ta.avoidPrivateLeaks(sym, tree.pos) tree } diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 13c3b7617..321c275d7 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -343,7 +343,6 @@ object Checking { fail(i"$sym cannot have the same name as ${cls.showLocated} -- class definitions cannot be overridden") sym.setFlag(Private) // break the overriding relationship by making sym Private } - avoidPrivateLeaks(sym, sym.pos) } /** Check the type signature of the symbol `M` defined by `tree` does not refer @@ -413,10 +412,6 @@ object Checking { info } - def avoidPrivateLeaks(sym: Symbol, pos: Position)(implicit ctx: Context) = - if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass) - sym.info = checkNoPrivateLeaks(sym, pos) - /** Verify classes extending AnyVal meet the requirements */ def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(implicit ctx: Context) = { def checkValueClassMember(stat: Tree) = stat match { diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 068ef3e4b..6bd8f6d06 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -668,13 +668,15 @@ class Namer { typer: Typer => * to pick up the context at the point where the completer was created. */ def completeInCreationContext(denot: SymDenotation): Unit = { + val sym = denot.symbol original match { - case original: MemberDef => addAnnotations(denot.symbol, original) + case original: MemberDef => addAnnotations(sym, original) case _ => } addInlineInfo(denot) - denot.info = typeSig(denot.symbol) - Checking.checkWellFormed(denot.symbol) + denot.info = typeSig(sym) + Checking.checkWellFormed(sym) + denot.info = avoidPrivateLeaks(sym, sym.pos) } } @@ -854,6 +856,7 @@ class Namer { typer: Typer => if (isDerivedValueClass(cls)) cls.setFlag(Final) cls.setApplicableFlags( (NoInitsInterface /: impl.body)((fs, stat) => fs & defKind(stat))) + cls.info = avoidPrivateLeaks(cls, cls.pos) } } diff --git a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala index 5c07b7bcf..53ce5555b 100644 --- a/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala +++ b/compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala @@ -132,6 +132,11 @@ trait TypeAssigner { def avoidingType(expr: Tree, bindings: List[Tree])(implicit ctx: Context): Type = avoid(expr.tpe, localSyms(bindings).filter(_.isTerm)) + def avoidPrivateLeaks(sym: Symbol, pos: Position)(implicit ctx: Context): Type = + if (!sym.is(SyntheticOrPrivate) && sym.owner.isClass) + Checking.checkNoPrivateLeaks(sym, pos) + else sym.info + def seqToRepeated(tree: Tree)(implicit ctx: Context): Tree = Typed(tree, TypeTree(tree.tpe.widen.translateParameterized(defn.SeqClass, defn.RepeatedParamClass))) |