summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-08-07 14:24:01 +0200
committerMartin Odersky <odersky@gmail.com>2012-08-07 14:24:01 +0200
commit90533942f06553178d2d453434f5836503e565b2 (patch)
tree95580e8eac18356ac7dd8a10a138a5d42df01036 /src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
parent114367c0b2ce5f48186d4270c1724090fd77877b (diff)
downloadscala-90533942f06553178d2d453434f5836503e565b2.tar.gz
scala-90533942f06553178d2d453434f5836503e565b2.tar.bz2
scala-90533942f06553178d2d453434f5836503e565b2.zip
Makes all private variables accessed from an @inline method non-private.
inlining across classes requires that accessed variables from @inline methods are not private.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index f0979978b0..a9bf849bee 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -46,13 +46,13 @@ abstract class ExplicitOuter extends InfoTransform
private def haveSameOuter(parent: Type, clazz: Symbol) = parent match {
case TypeRef(pre, sym, _) =>
val owner = clazz.owner
-
+
//println(s"have same outer $parent $clazz $sym ${sym.owner} $owner $pre")
sym.isClass && owner.isClass &&
- (owner isSubClass sym.owner) &&
+ (owner isSubClass sym.owner) &&
owner.thisType =:= pre
-
+
case _ => false
}
@@ -497,8 +497,18 @@ abstract class ExplicitOuter extends InfoTransform
else atPos(tree.pos)(outerPath(outerValue, currentClass.outerClass, sym)) // (5)
case Select(qual, name) =>
- if (currentClass != sym.owner) // (3)
+ /** return closest enclosing method, unless shadowed by an enclosing class;
+ * no use of closures here in the interest of speed.
+ */
+ def closestEnclMethod(from: Symbol): Symbol =
+ if (from.isSourceMethod) from
+ else if (from.isClass) NoSymbol
+ else closestEnclMethod(from.owner)
+
+ if (currentClass != sym.owner ||
+ (closestEnclMethod(currentOwner) hasAnnotation ScalaInlineClass))
sym.makeNotPrivate(sym.owner)
+
val qsym = qual.tpe.widen.typeSymbol
if (sym.isProtected && //(4)
(qsym.isTrait || !(qual.isInstanceOf[Super] || (qsym isSubClass currentClass))))