aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-09-06 11:41:12 +0200
committerMartin Odersky <odersky@gmail.com>2014-09-06 11:41:12 +0200
commitb129332c273374018bfdd8a51bbec761118c9d9c (patch)
tree91648f4e855f90101ae557c07d51610cfa6b99f4 /src
parentc3078b12582773e3a9bb356e168fb646ec6733b1 (diff)
downloaddotty-b129332c273374018bfdd8a51bbec761118c9d9c.tar.gz
dotty-b129332c273374018bfdd8a51bbec761118c9d9c.tar.bz2
dotty-b129332c273374018bfdd8a51bbec761118c9d9c.zip
Move explicit outer after pattern matching
But allow pattern matching to provide outer accessors when needed using with ensureOuterAccessors.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala3
-rw-r--r--src/dotty/tools/dotc/transform/ExplicitOuter.scala7
2 files changed, 8 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index 377f9fbdc..cd5ef4cae 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -54,8 +54,9 @@ class Compiler {
new ElimRepeated,
new ElimLocals),
List(new ExtensionMethods),
- List(new TailRec, new ExplicitOuter),
+ List(new TailRec),
List(new PatternMatcher,
+ new ExplicitOuter,
// new LazyValTranformContext().transformer, // disabled, awaiting fixes
new Splitter),
List(new ElimByName,
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
index f910f49d0..b9c9617a8 100644
--- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala
+++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
@@ -69,6 +69,11 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
private def newOuterAccessors(cls: ClassSymbol)(implicit ctx: Context) =
newOuterAccessor(cls, cls) :: (if (cls is Trait) Nil else newOuterParamAccessor(cls) :: Nil)
+ /** Ensure that class `cls` has outer accessors */
+ def ensureOuterAccessors(cls: ClassSymbol)(implicit ctx: Context): Unit = {
+ if (!hasOuter(cls)) newOuterAccessors(cls).foreach(_.enteredAfter(thisTransformer))
+ }
+
/** First, add outer accessors if a class does not have them yet and it references an outer this.
* If the class has outer accessors, implement them.
* Furthermore, if a parent trait might have an outer accessor,
@@ -86,7 +91,7 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
if (needsOuterIfReferenced(cls) &&
!needsOuterAlways(cls) &&
impl.existsSubTree(referencesOuter(cls, _)))
- newOuterAccessors(cls).foreach(_.enteredAfter(thisTransformer))
+ ensureOuterAccessors(cls)
if (hasOuter(cls)) {
val newDefs = new mutable.ListBuffer[Tree]
if (isTrait)