diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-06 11:41:12 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-09-06 11:41:12 +0200 |
commit | b129332c273374018bfdd8a51bbec761118c9d9c (patch) | |
tree | 91648f4e855f90101ae557c07d51610cfa6b99f4 /src/dotty/tools/dotc/transform/ExplicitOuter.scala | |
parent | c3078b12582773e3a9bb356e168fb646ec6733b1 (diff) | |
download | dotty-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/dotty/tools/dotc/transform/ExplicitOuter.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala | 7 |
1 files changed, 6 insertions, 1 deletions
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) |