diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-01 15:55:09 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-01 18:46:28 +0100 |
commit | 67de3d35019816a1297215770f1a8012c390db0e (patch) | |
tree | d772338aef6b0505a18a9510d3148b8bab0aae4a /src/dotty/tools/dotc/transform/ExplicitOuter.scala | |
parent | adc4f8295eecc2c802067ff7375006564700fff6 (diff) | |
download | dotty-67de3d35019816a1297215770f1a8012c390db0e.tar.gz dotty-67de3d35019816a1297215770f1a8012c390db0e.tar.bz2 dotty-67de3d35019816a1297215770f1a8012c390db0e.zip |
Fix outer paths generated during lambda lift from constructors.
If lambda lift needs to create an outer path from a constructor, the
path needs to start from the $outer parameter of the constructor, not
the this of the enclosing class, which is not yet available.
Diffstat (limited to 'src/dotty/tools/dotc/transform/ExplicitOuter.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 3f93e6407..4cf076c45 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -313,7 +313,7 @@ object ExplicitOuter { /** The path of outer accessors that references `toCls.this` starting from * the context owner's this node. */ - def path(toCls: Symbol): Tree = try { + def path(toCls: Symbol, start: Tree = This(ctx.owner.enclosingClass.asClass)): Tree = try { def loop(tree: Tree): Tree = { val treeCls = tree.tpe.widen.classSymbol val outerAccessorCtx = ctx.withPhaseNoLater(ctx.lambdaLiftPhase) // lambdalift mangles local class names, which means we cannot reliably find outer acessors anymore @@ -322,7 +322,7 @@ object ExplicitOuter { else loop(tree.select(outerAccessor(treeCls.asClass)(outerAccessorCtx)).ensureApplied) } ctx.log(i"computing outerpath to $toCls from ${ctx.outersIterator.map(_.owner).toList}") - loop(This(ctx.owner.enclosingClass.asClass)) + loop(start) } catch { case ex: ClassCastException => throw new ClassCastException(i"no path exists from ${ctx.owner.enclosingClass} to $toCls") |