diff options
-rw-r--r-- | src/dotty/tools/dotc/core/Phases.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/FirstTransform.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/RefChecks.scala | 3 |
5 files changed, 19 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala index 27b7cd77d..5eb8cd920 100644 --- a/src/dotty/tools/dotc/core/Phases.scala +++ b/src/dotty/tools/dotc/core/Phases.scala @@ -9,11 +9,10 @@ import Denotations._ import config.Printers._ import scala.collection.mutable.{ListBuffer, ArrayBuffer} import dotty.tools.dotc.transform.TreeTransforms.{TreeTransformer, MiniPhase, TreeTransform} -import dotty.tools.dotc.transform.TreeTransforms +import dotty.tools.dotc.transform.{ExplicitOuter, TreeTransforms, Erasure, Flatten} import Periods._ import typer.{FrontEnd, RefChecks} import ast.tpd -import dotty.tools.dotc.transform.{Erasure, Flatten} trait Phases { self: Context => @@ -169,11 +168,13 @@ object Phases { private val refChecksCache = new PhaseCache(classOf[RefChecks]) private val erasureCache = new PhaseCache(classOf[Erasure]) private val flattenCache = new PhaseCache(classOf[Flatten]) + private val explicitOuterCache = new PhaseCache(classOf[ExplicitOuter]) def typerPhase = typerCache.phase def refchecksPhase = refChecksCache.phase def erasurePhase = erasureCache.phase def flattenPhase = flattenCache.phase + def explicitOuter = explicitOuterCache.phase def isAfterTyper(phase: Phase): Boolean = phase.id > typerPhase.id } diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index aed55e49a..88f75fbfd 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -200,7 +200,7 @@ object SymDenotations { final def hasAnnotation(cls: Symbol)(implicit ctx: Context) = dropOtherAnnotations(annotations, cls).nonEmpty - /** Optionally, the arguments of the first annotation matching the given class symbol */ + /** Optionally, get annotation matching the given class symbol */ final def getAnnotation(cls: Symbol)(implicit ctx: Context): Option[Annotation] = dropOtherAnnotations(annotations, cls) match { case annot :: _ => Some(annot) diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 669660b1f..a814f302f 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -29,7 +29,7 @@ import collection.mutable * - replace outer this by outer paths. */ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransformer => - import ExplicitOuter._ + imoport ExplicitOuter._ import ast.tpd._ val Outer = new Attachment.Key[Tree] @@ -71,7 +71,10 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf /** Ensure that class `cls` has outer accessors */ def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit = { - if (!hasOuter(cls)) newOuterAccessors(cls).foreach(_.enteredAfter(thisTransformer)) + if (!hasOuter(cls)) { + assert(ctx.phaseId <= ctx.explicitOuter.id, "can add $outer symbols only before ExplicitOuter") + newOuterAccessors(cls).foreach(_.enteredAfter(thisTransformer)) + } } /** First, add outer accessors if a class does not have them yet and it references an outer this. diff --git a/src/dotty/tools/dotc/transform/FirstTransform.scala b/src/dotty/tools/dotc/transform/FirstTransform.scala index 5a3e65294..a8cbb0595 100644 --- a/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -85,7 +85,13 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer { if (tree.isType) TypeTree(tree.tpe).withPos(tree.pos) else tree override def transformIdent(tree: Ident)(implicit ctx: Context, info: TransformerInfo) = tree.tpe match { - case tpe: ThisType => This(tpe.cls).withPos(tree.pos) + case tpe: ThisType => + /* + A this reference hide in a self ident, and be subsequently missed + when deciding on whether outer accessors are needed and computing outer paths. + sWe do this normalization directly after Typer, because during typer the + ident should rest available for hyperlinking.*/ + This(tpe.cls).withPos(tree.pos) case _ => normalizeType(tree) } diff --git a/src/dotty/tools/dotc/typer/RefChecks.scala b/src/dotty/tools/dotc/typer/RefChecks.scala index e338aa392..2b81af5cb 100644 --- a/src/dotty/tools/dotc/typer/RefChecks.scala +++ b/src/dotty/tools/dotc/typer/RefChecks.scala @@ -691,6 +691,9 @@ import RefChecks._ * Unlike in Scala 2.x not-private members keep their name. It is * up to the backend to find a unique expanded name for them. The * rationale to do name changes that late is that they are very fragile. + + * todo: But RefChecks is not done yet. It's still a somewhat dirty port from the Scala 2 version. + * todo: move untrivial logic to their own mini-phases */ class RefChecks extends MiniPhase with SymTransformer { thisTransformer => |