diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-06 05:06:16 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-09-06 05:06:16 +0200 |
commit | 44bdec1a44db7ac880183e0c70b5f5668048961e (patch) | |
tree | a8e2903253d74aa56d98388fa14be89324cc93ec /src | |
parent | a661bed267745d5f19f967712462b3f038ad8dcd (diff) | |
download | dotty-44bdec1a44db7ac880183e0c70b5f5668048961e.tar.gz dotty-44bdec1a44db7ac880183e0c70b5f5668048961e.tar.bz2 dotty-44bdec1a44db7ac880183e0c70b5f5668048961e.zip |
Rename OuterAccessors to ExplicitOuter
Better to keep the old name for easy cross-referencing with Scala 2.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/Compiler.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/TypeErasure.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/Erasure.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala (renamed from src/dotty/tools/dotc/transform/OuterAccessors.scala) | 31 |
4 files changed, 23 insertions, 14 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala index 060f1fcbd..377f9fbdc 100644 --- a/src/dotty/tools/dotc/Compiler.scala +++ b/src/dotty/tools/dotc/Compiler.scala @@ -54,7 +54,7 @@ class Compiler { new ElimRepeated, new ElimLocals), List(new ExtensionMethods), - List(new TailRec, new OuterAccessors), + List(new TailRec, new ExplicitOuter), List(new PatternMatcher, // new LazyValTranformContext().transformer, // disabled, awaiting fixes new Splitter), diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala index 3b7dd7460..d46c64006 100644 --- a/src/dotty/tools/dotc/TypeErasure.scala +++ b/src/dotty/tools/dotc/TypeErasure.scala @@ -3,7 +3,7 @@ package dotc package core import Symbols._, Types._, Contexts._, Flags._, Names._, StdNames._, Decorators._, Flags.JavaDefined -import dotc.transform.OuterAccessors._ +import dotc.transform.ExplicitOuter._ import util.DotClass /** Erased types are: diff --git a/src/dotty/tools/dotc/transform/Erasure.scala b/src/dotty/tools/dotc/transform/Erasure.scala index a5679d598..82acb482d 100644 --- a/src/dotty/tools/dotc/transform/Erasure.scala +++ b/src/dotty/tools/dotc/transform/Erasure.scala @@ -24,7 +24,7 @@ import scala.collection.mutable.ListBuffer import dotty.tools.dotc.core.Flags import ValueClasses._ import TypeUtils._ -import OuterAccessors._ +import ExplicitOuter._ import typer.Mode class Erasure extends Phase with DenotTransformer { thisTransformer => diff --git a/src/dotty/tools/dotc/transform/OuterAccessors.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 74371486c..0a1c94dd1 100644 --- a/src/dotty/tools/dotc/transform/OuterAccessors.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -16,17 +16,26 @@ import SymUtils._ import util.Attachment import collection.mutable -/** This phase decorates News and parent constructors of non-static inner classes - * with an attachment indicating the outer reference as a tree. This is necessary because - * outer prefixes are erased, and explicit outer runs only after erasure. +/** This phase adds outer accessors to classes and traits that need them. + * Compared to Scala 2.x, it tries to minimize the set of classes + * that take outer accessors and also tries to minimize the number + * of objects referred to by outer accessors. This helps prevent space + * leaks. + * + * The following things are delayed until erasure and are performed + * by class OuterOps: + * + * - add outer parameters to constructors + * - pass outer arguments in constructor calls + * - replace outer this by outer paths. */ -class OuterAccessors extends MiniPhaseTransform with InfoTransformer { thisTransformer => - import OuterAccessors._ +class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransformer => + import ExplicitOuter._ import ast.tpd._ val Outer = new Attachment.Key[Tree] - override def phaseName: String = "outerAccessors" + override def phaseName: String = "ExplicitOuter" override def treeTransformPhase = thisTransformer.next @@ -34,7 +43,7 @@ class OuterAccessors extends MiniPhaseTransform with InfoTransformer { thisTrans override def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context) = tp match { case tp @ ClassInfo(_, cls, _, decls, _) if needsOuterAlways(cls) => val newDecls = decls.cloneScope - newOuterAccessors(cls).foreach(newDecls.enter) + newExplicitOuter(cls).foreach(newDecls.enter) tp.derivedClassInfo(decls = newDecls) case _ => tp @@ -58,7 +67,7 @@ class OuterAccessors extends MiniPhaseTransform with InfoTransformer { thisTrans newOuterSym(cls, cls, nme.OUTER, Private | ParamAccessor) /** The outer accessor and potentially outer param accessor needed for class `cls` */ - private def newOuterAccessors(cls: ClassSymbol)(implicit ctx: Context) = + private def newExplicitOuter(cls: ClassSymbol)(implicit ctx: Context) = newOuterAccessor(cls, cls) :: (if (cls is Trait) Nil else newOuterParamAccessor(cls) :: Nil) /** First, add outer accessors if a class does not have them yet and it references an outer this. @@ -76,7 +85,7 @@ class OuterAccessors extends MiniPhaseTransform with InfoTransformer { thisTrans val cls = ctx.owner.asClass val isTrait = cls.is(Trait) if (needsOuterIfReferenced(cls) && !needsOuterAlways(cls) && referencesOuter(cls, impl)) - newOuterAccessors(cls).foreach(_.enteredAfter(thisTransformer)) + newExplicitOuter(cls).foreach(_.enteredAfter(thisTransformer)) if (hasOuter(cls)) { val newDefs = new mutable.ListBuffer[Tree] if (isTrait) @@ -107,7 +116,7 @@ class OuterAccessors extends MiniPhaseTransform with InfoTransformer { thisTrans } } -object OuterAccessors { +object ExplicitOuter { import ast.tpd._ private val LocalInstantiationSite = Module | Private @@ -146,7 +155,7 @@ object OuterAccessors { cls.info.member(outerAccName(cls)).suchThat(_ is OuterAccessor).symbol orElse cls.info.decls.find(_ is OuterAccessor).getOrElse(NoSymbol) - /** Class has an outer accessor. Can be called only after phase OuterAccessors. */ + /** Class has an outer accessor. Can be called only after phase ExplicitOuter. */ private def hasOuter(cls: ClassSymbol)(implicit ctx: Context): Boolean = needsOuterIfReferenced(cls) && outerAccessor(cls).exists |