summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2014-01-27 15:45:18 +0300
committerEugene Burmako <xeno.by@gmail.com>2014-02-12 14:53:48 +0100
commitc34b24a6c4b75a6215bdb8fd8ff94ce869430435 (patch)
tree4792a96322e2f30b7fe1830091cf748503636bfc /src/compiler/scala/tools/nsc/transform/LambdaLift.scala
parent7c06c9d7f6a12c2b13c83b195fffa30c5a4ec3ce (diff)
downloadscala-c34b24a6c4b75a6215bdb8fd8ff94ce869430435.tar.gz
scala-c34b24a6c4b75a6215bdb8fd8ff94ce869430435.tar.bz2
scala-c34b24a6c4b75a6215bdb8fd8ff94ce869430435.zip
disambiguates uses of “local” in internal symbol API
There’s been a conflation of two distinct meanings of the word “local” in the internal symbol API: the first meaning being “local to this” (as in has the LOCAL flag set), the second meaning being “local to block” (as in declared in a block, i.e. having owner being a term symbol). Especially confusing is the fact that sym.isLocal isn’t the same as sym.hasFlag(LOCAL), which has led to now fixed SI-6733. This commit fixes the semantic mess by deprecating both Symbol.isLocal and Symbol.hasLocalFlag (that we were forced to use, because Symbol.isLocal had already been taken), and replacing them with Symbol.isLocalToThis and Symbol.isLocalToBlock. Unfortunately, we can’t remove the deprecated methods right away, because they are used in SBT, so I had to take small steps.
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/LambdaLift.scala')
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index acef2a50d8..e38c034f4d 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -122,7 +122,7 @@ abstract class LambdaLift extends InfoTransform {
* and the owner of `sym`.
* Return `true` if there is no class between `enclosure` and
* the owner of sym.
- * pre: sym.isLocal, (enclosure.isMethod || enclosure.isClass)
+ * pre: sym.isLocalToBlock, (enclosure.isMethod || enclosure.isClass)
*
* The idea of `markFree` is illustrated with an example:
*
@@ -180,7 +180,7 @@ abstract class LambdaLift extends InfoTransform {
tree match {
case ClassDef(_, _, _, _) =>
liftedDefs(tree.symbol) = Nil
- if (sym.isLocal) {
+ if (sym.isLocalToBlock) {
// Don't rename implementation classes independently of their interfaces. If
// the interface is to be renamed, then we will rename the implementation
// class at that time. You'd think we could call ".implClass" on the trait
@@ -201,7 +201,7 @@ abstract class LambdaLift extends InfoTransform {
}
}
case DefDef(_, _, _, _, _, _) =>
- if (sym.isLocal) {
+ if (sym.isLocalToBlock) {
renamable += sym
sym setFlag (PrivateLocal | FINAL)
} else if (sym.isPrimaryConstructor) {
@@ -210,14 +210,14 @@ abstract class LambdaLift extends InfoTransform {
case Ident(name) =>
if (sym == NoSymbol) {
assert(name == nme.WILDCARD)
- } else if (sym.isLocal) {
+ } else if (sym.isLocalToBlock) {
val owner = currentOwner.logicallyEnclosingMember
if (sym.isTerm && !sym.isMethod) markFree(sym, owner)
else if (sym.isMethod) markCalled(sym, owner)
//symSet(called, owner) += sym
}
case Select(_, _) =>
- if (sym.isConstructor && sym.owner.isLocal)
+ if (sym.isConstructor && sym.owner.isLocalToBlock)
markCalled(sym, currentOwner.logicallyEnclosingMember)
case _ =>
}
@@ -362,7 +362,7 @@ abstract class LambdaLift extends InfoTransform {
private def proxyRef(sym: Symbol) = {
val psym = proxy(sym)
- if (psym.isLocal) gen.mkAttributedIdent(psym) else memberRef(psym)
+ if (psym.isLocalToBlock) gen.mkAttributedIdent(psym) else memberRef(psym)
}
private def addFreeArgs(pos: Position, sym: Symbol, args: List[Tree]) = {
@@ -459,10 +459,10 @@ abstract class LambdaLift extends InfoTransform {
tree match {
case ClassDef(_, _, _, _) =>
val tree1 = addFreeParams(tree, sym)
- if (sym.isLocal) liftDef(tree1) else tree1
+ if (sym.isLocalToBlock) liftDef(tree1) else tree1
case DefDef(_, _, _, _, _, _) =>
val tree1 = addFreeParams(tree, sym)
- if (sym.isLocal) liftDef(tree1) else tree1
+ if (sym.isLocalToBlock) liftDef(tree1) else tree1
case ValDef(mods, name, tpt, rhs) =>
if (sym.isCapturedVariable) {
val tpt1 = TypeTree(sym.tpe) setPos tpt.pos
@@ -499,7 +499,7 @@ abstract class LambdaLift extends InfoTransform {
if (sym.isTerm && !sym.isLabel)
if (sym.isMethod)
atPos(tree.pos)(memberRef(sym))
- else if (sym.isLocal && !isSameOwnerEnclosure(sym))
+ else if (sym.isLocalToBlock && !isSameOwnerEnclosure(sym))
atPos(tree.pos)(proxyRef(sym))
else tree
else tree