aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2015-11-09 11:30:41 +0100
committerDmitry Petrashko <dark@d-d.me>2015-11-09 11:30:41 +0100
commit8eef182cfab2d4a23924c4478809d6e83bfc0b9b (patch)
treec1088ab653cd40f8c9494498d9cbb15464c97677
parent8c593779fd49f9085f69b6b5a9fe180ebede801e (diff)
parent4d39003f3ca112d03af1e7a51c9e59bf5eb510c5 (diff)
downloaddotty-8eef182cfab2d4a23924c4478809d6e83bfc0b9b.tar.gz
dotty-8eef182cfab2d4a23924c4478809d6e83bfc0b9b.tar.bz2
dotty-8eef182cfab2d4a23924c4478809d6e83bfc0b9b.zip
Merge pull request #899 from dotty-staging/fix-#880
Require outer pointer also for proxies of enclosing classes.
-rw-r--r--src/dotty/tools/dotc/transform/ExplicitOuter.scala11
-rw-r--r--tests/pos/i880.scala17
2 files changed, 25 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
index 7391f3cec..024247734 100644
--- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala
+++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala
@@ -220,9 +220,14 @@ object ExplicitOuter {
case id: Ident =>
id.tpe match {
case ref @ TermRef(NoPrefix, _) =>
- ref.symbol.is(Hoistable) && isOuter(id.symbol.owner.enclosingClass)
- // methods will be placed in enclosing class scope by LambdaLift, so they will get
- // an outer path then.
+ if (ref.symbol is Hoistable)
+ // ref.symbol will be placed in enclosing class scope by LambdaLift, so it might need
+ // an outer path then.
+ isOuter(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)
case _ => false
}
case nw: New =>
diff --git a/tests/pos/i880.scala b/tests/pos/i880.scala
new file mode 100644
index 000000000..0f2b642ef
--- /dev/null
+++ b/tests/pos/i880.scala
@@ -0,0 +1,17 @@
+object Test {
+ def test = {
+ val myName: String = ""
+ new AnyRef {
+ new Exception {
+ def name = myName
+ }
+ }
+ new AnyRef {
+ new Exception {
+ new AnyRef {
+ def name = myName
+ }
+ }
+ }
+ }
+}