aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/transform/ExplicitOuter.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-03-01 15:30:31 +0100
committerMartin Odersky <odersky@gmail.com>2016-03-01 18:46:27 +0100
commitadc4f8295eecc2c802067ff7375006564700fff6 (patch)
tree9a32c566f2f3662b141411f26f352d71e26ba58b /src/dotty/tools/dotc/transform/ExplicitOuter.scala
parentba67e556271156c11f5f313f68891bf18f7a51d2 (diff)
downloaddotty-adc4f8295eecc2c802067ff7375006564700fff6.tar.gz
dotty-adc4f8295eecc2c802067ff7375006564700fff6.tar.bz2
dotty-adc4f8295eecc2c802067ff7375006564700fff6.zip
Fix a loophole where outer paths are missing at phase lambda lift.
Test will come in llift.scala.
Diffstat (limited to 'src/dotty/tools/dotc/transform/ExplicitOuter.scala')
-rw-r--r--src/dotty/tools/dotc/transform/ExplicitOuter.scala9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
index 024247734..3f93e6407 100644
--- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala
+++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
@@ -209,7 +209,7 @@ object ExplicitOuter {
private def hasOuterParam(cls: ClassSymbol)(implicit ctx: Context): Boolean =
!cls.is(Trait) && needsOuterIfReferenced(cls) && outerAccessor(cls).exists
- /** Tree references a an outer class of `cls` which is not a static owner.
+ /** Tree references an outer class of `cls` which is not a static owner.
*/
def referencesOuter(cls: Symbol, tree: Tree)(implicit ctx: Context): Boolean = {
def isOuter(sym: Symbol) =
@@ -231,7 +231,12 @@ object ExplicitOuter {
case _ => false
}
case nw: New =>
- isOuter(nw.tpe.classSymbol.owner.enclosingClass)
+ val newCls = nw.tpe.classSymbol
+ isOuter(newCls.owner.enclosingClass) ||
+ newCls.owner.isTerm && cls.isProperlyContainedIn(newCls)
+ // newCls might get proxies for free variables. If current class is
+ // properly contained in newCls, it needs an outer path to newCls access the
+ // proxies and forward them to the new instance.
case _ =>
false
}