File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed
src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -226,14 +226,18 @@ object ExplicitOuter {
226226 case ref : TermRef =>
227227 if (ref.prefix ne NoPrefix )
228228 ! ref.symbol.isStatic && isOuterRef(ref.prefix)
229- else if (ref.symbol is Hoistable )
230- // ref.symbol will be placed in enclosing class scope by LambdaLift, so it might need
231- // an outer path then.
232- isOuterSym(ref.symbol.owner.enclosingClass)
233- else
234- // ref.symbol will get a proxy in immediately enclosing class. If this properly
235- // contains the current class, it needs an outer path.
236- ctx.owner.enclosingClass.owner.enclosingClass.isContainedIn(ref.symbol.owner)
229+ else (
230+ (ref.symbol is Hoistable ) &&
231+ // ref.symbol will be placed in enclosing class scope by LambdaLift, so it might need
232+ // an outer path then.
233+ isOuterSym(ref.symbol.owner.enclosingClass)
234+ ||
235+ // If not hoistable, ref.symbol will get a proxy in immediately enclosing class. If this properly
236+ // contains the current class, it needs an outer path.
237+ // If the symbol is hoistable, it might have free variables for which the same
238+ // reasoning applies. See pos/i1664.scala
239+ ctx.owner.enclosingClass.owner.enclosingClass.isContainedIn(ref.symbol.owner)
240+ )
237241 case _ => false
238242 }
239243 def hasOuterPrefix (tp : Type ) = tp match {
Original file line number Diff line number Diff line change 1+ object test {
2+ def f [a](x : a) = {
3+ def print = x
4+ class A {
5+ def f () = {
6+ class B { def h = print }
7+ new B
8+ }
9+ f()
10+ }
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments