diff options
author | Martin Odersky <odersky@gmail.com> | 2016-11-10 15:29:01 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-11-10 15:31:18 +0100 |
commit | 4b1f5daa63afc29d4d7f8c5959e56d2e8bc998e1 (patch) | |
tree | 5a2aaaca35c20a34ba6dd76c36b6e3f43c2c5941 /src/dotty/tools/dotc/transform | |
parent | 28c2e04dd33b6389a44460f977a97b8691265994 (diff) | |
download | dotty-4b1f5daa63afc29d4d7f8c5959e56d2e8bc998e1.tar.gz dotty-4b1f5daa63afc29d4d7f8c5959e56d2e8bc998e1.tar.bz2 dotty-4b1f5daa63afc29d4d7f8c5959e56d2e8bc998e1.zip |
Fix #1664: Refine isOuterRef condition
We forgot the case where a hoistable method can still
refer to free variables that have to be passed using
outer pointers.
Fixes #1664.
Diffstat (limited to 'src/dotty/tools/dotc/transform')
-rw-r--r-- | src/dotty/tools/dotc/transform/ExplicitOuter.scala | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 3f235dca7..3fec47e9f 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -226,14 +226,18 @@ object ExplicitOuter { case ref: TermRef => if (ref.prefix ne NoPrefix) !ref.symbol.isStatic && isOuterRef(ref.prefix) - else if (ref.symbol is Hoistable) - // ref.symbol will be placed in enclosing class scope by LambdaLift, so it might need - // an outer path then. - isOuterSym(ref.symbol.owner.enclosingClass) - else - // ref.symbol will get a proxy in immediately enclosing class. If this properly - // contains the current class, it needs an outer path. - ctx.owner.enclosingClass.owner.enclosingClass.isContainedIn(ref.symbol.owner) + else ( + (ref.symbol is Hoistable) && + // ref.symbol will be placed in enclosing class scope by LambdaLift, so it might need + // an outer path then. + isOuterSym(ref.symbol.owner.enclosingClass) + || + // If not hoistable, ref.symbol will get a proxy in immediately enclosing class. If this properly + // contains the current class, it needs an outer path. + // If the symbol is hoistable, it might have free variables for which the same + // reasoning applies. See pos/i1664.scala + ctx.owner.enclosingClass.owner.enclosingClass.isContainedIn(ref.symbol.owner) + ) case _ => false } def hasOuterPrefix(tp: Type) = tp match { |