diff options
author | Martin Odersky <odersky@gmail.com> | 2015-06-03 17:59:16 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2015-06-03 18:10:45 +0200 |
commit | 6c8a2425148753d040ab2dbde6ac57349893b736 (patch) | |
tree | 55c1df0e45cab59dd4c373091e09fb51d6d7c398 /src/dotty/tools/dotc | |
parent | 5cb4ecb19cb551609ebee97aa1b199de8468a98a (diff) | |
download | dotty-6c8a2425148753d040ab2dbde6ac57349893b736.tar.gz dotty-6c8a2425148753d040ab2dbde6ac57349893b736.tar.bz2 dotty-6c8a2425148753d040ab2dbde6ac57349893b736.zip |
Compute outer.path in lambdaLift at correct phase.
LambdaLift needs to compute outer.path at the phase in which
the results are constructed, i.e. phase lambdaLift.next. Or else
we get an error in outer.path for lost fo files, including pos/Fileish.scala
as a minimized test case. Previously outer as computed at phase lambdaLift.
The reason for this is that lambdaLift name mangles inner classes, which
causes outer acessors to be not found. We now correct for the problem
in outer.path itself, by calling outerAccessor only at a safe phase.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/LambdaLift.scala | 4 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index c1b2e20eb..b00896117 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -231,6 +231,9 @@ object Contexts { final def withPhase(phase: Phase): Context = withPhase(phase.id) + final def withPhaseNoLater(phase: Phase) = + if (ctx.phase.id > phase.id) withPhase(phase) else ctx + /** If -Ydebug is on, the top of the stack trace where this context * was created, otherwise `null`. */ diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 70a4f299a..0fa429d6e 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -299,9 +299,10 @@ object ExplicitOuter { def path(toCls: Symbol): Tree = try { def loop(tree: Tree): Tree = { val treeCls = tree.tpe.widen.classSymbol - ctx.log(i"outer to $toCls of $tree: ${tree.tpe}, looking for ${outerAccName(treeCls.asClass)}") + val outerAccessorCtx = ctx.withPhaseNoLater(ctx.lambdaLiftPhase) // lambdalift mangles local class names, which means we cannot reliably find outer acessors anymore + ctx.log(i"outer to $toCls of $tree: ${tree.tpe}, looking for ${outerAccName(treeCls.asClass)(outerAccessorCtx)} in $treeCls") if (treeCls == toCls) tree - else loop(tree select outerAccessor(treeCls.asClass)) + else loop(tree select outerAccessor(treeCls.asClass)(outerAccessorCtx)) } ctx.log(i"computing outerpath to $toCls from ${ctx.outersIterator.map(_.owner).toList}") loop(This(ctx.owner.enclosingClass.asClass)) diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala index 306a03642..bffc7458e 100644 --- a/src/dotty/tools/dotc/transform/LambdaLift.scala +++ b/src/dotty/tools/dotc/transform/LambdaLift.scala @@ -94,7 +94,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform * than the previous value of `liftedowner(sym)`. */ def narrowLiftedOwner(sym: Symbol, owner: Symbol)(implicit ctx: Context) = { - if (sym.owner.isTerm && + if (sym.maybeOwner.isTerm && owner.isProperlyContainedIn(liftedOwner(sym)) && owner != sym) { ctx.log(i"narrow lifted $sym to $owner") @@ -366,7 +366,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform val clazz = sym.enclosingClass val qual = if (clazz.isStaticOwner) singleton(clazz.thisType) - else outer(ctx.withPhase(thisTransform)).path(clazz) + else outer.path(clazz) transformFollowingDeep(qual.select(sym)) } |