diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-27 15:45:18 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-12 14:53:48 +0100 |
commit | c34b24a6c4b75a6215bdb8fd8ff94ce869430435 (patch) | |
tree | 4792a96322e2f30b7fe1830091cf748503636bfc /src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | |
parent | 7c06c9d7f6a12c2b13c83b195fffa30c5a4ec3ce (diff) | |
download | scala-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/typechecker/RefChecks.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 2125e281f0..8acc682063 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -903,7 +903,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans var index = -1 for (stat <- stats) { index = index + 1 - def enterSym(sym: Symbol) = if (sym.isLocal) { + def enterSym(sym: Symbol) = if (sym.isLocalToBlock) { currentLevel.scope.enter(sym) symIndex(sym) = index } @@ -920,7 +920,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans } private def enterReference(pos: Position, sym: Symbol) { - if (sym.isLocal) { + if (sym.isLocalToBlock) { val e = currentLevel.scope.lookupEntry(sym.name) if ((e ne null) && sym == e.sym) { var l = currentLevel @@ -1225,7 +1225,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans if (tree1.symbol.isLazy) tree1 :: Nil else { val lazySym = tree.symbol.lazyAccessorOrSelf - if (lazySym.isLocal && index <= currentLevel.maxindex) { + if (lazySym.isLocalToBlock && index <= currentLevel.maxindex) { debuglog("refsym = " + currentLevel.refsym) unit.error(currentLevel.refpos, "forward reference extends over definition of " + lazySym) } @@ -1544,7 +1544,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans if (!sym.exists) devWarning("Select node has NoSymbol! " + tree + " / " + tree.tpe) - else if (sym.hasLocalFlag) + else if (sym.isLocalToThis) varianceValidator.checkForEscape(sym, currentClass) def checkSuper(mix: Name) = @@ -1753,7 +1753,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans result match { case ClassDef(_, _, _, _) | TypeDef(_, _, _, _) => - if (result.symbol.isLocal || result.symbol.isTopLevel) + if (result.symbol.isLocalToBlock || result.symbol.isTopLevel) varianceValidator.traverse(result) case tt @ TypeTree() if tt.original != null => varianceValidator.traverse(tt.original) // See SI-7872 |