Skip to content

Commit 4d39003

Browse files
committed
Require outer pointer also for proxies of enclosing classes.
There was a missing case where an outer pointer is required.
1 parent 08e8802 commit 4d39003

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,14 @@ object ExplicitOuter {
220220
case id: Ident =>
221221
id.tpe match {
222222
case ref @ TermRef(NoPrefix, _) =>
223-
ref.symbol.is(Hoistable) && isOuter(id.symbol.owner.enclosingClass)
224-
// methods will be placed in enclosing class scope by LambdaLift, so they will get
225-
// an outer path then.
223+
if (ref.symbol is Hoistable)
224+
// ref.symbol will be placed in enclosing class scope by LambdaLift, so it might need
225+
// an outer path then.
226+
isOuter(ref.symbol.owner.enclosingClass)
227+
else
228+
// ref.symbol will get a proxy in immediately enclosing class. If this properly
229+
// contains the current class, it needs an outer path.
230+
ctx.owner.enclosingClass.owner.enclosingClass.isContainedIn(ref.symbol.owner)
226231
case _ => false
227232
}
228233
case nw: New =>

tests/pos/i880.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
object Test {
2+
def test = {
3+
val myName: String = ""
4+
new AnyRef {
5+
new Exception {
6+
def name = myName
7+
}
8+
}
9+
new AnyRef {
10+
new Exception {
11+
new AnyRef {
12+
def name = myName
13+
}
14+
}
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)