summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Symbols.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/reflect/scala/reflect/internal/Symbols.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/reflect/scala/reflect/internal/Symbols.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index 6fedb74f86..f2b3d52c6f 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -901,7 +901,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
|| isModuleOrModuleClass && (isTopLevel || !settings.overrideObjects)
|| isTerm && (
isPrivate
- || isLocal
+ || isLocalToBlock
|| isNotOverridden
)
)
@@ -909,9 +909,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** Is this symbol owned by a package? */
final def isTopLevel = owner.isPackageClass
- /** Is this symbol locally defined? I.e. not accessed from outside `this` instance */
+ /** Is this symbol defined in a block? */
+ @deprecated("Use isLocalToBlock instead", "2.11.0")
final def isLocal: Boolean = owner.isTerm
+ /** Is this symbol defined in a block? */
+ final def isLocalToBlock: Boolean = owner.isTerm
+
/** Is this symbol a constant? */
final def isConstant: Boolean = isStable && isConstantType(tpe.resultType)
@@ -1254,7 +1258,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* as public.
*/
def accessBoundary(base: Symbol): Symbol = {
- if (hasFlag(PRIVATE) || isLocal) owner
+ if (hasFlag(PRIVATE) || isLocalToBlock) owner
else if (hasAllFlags(PROTECTED | STATIC | JAVA)) enclosingRootClass
else if (hasAccessBoundary && !phase.erasedTypes) privateWithin
else if (hasFlag(PROTECTED)) base
@@ -2819,7 +2823,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
class AliasTypeSymbol protected[Symbols] (initOwner: Symbol, initPos: Position, initName: TypeName)
extends TypeSymbol(initOwner, initPos, initName) {
type TypeOfClonedSymbol = TypeSymbol
- override def variance = if (hasLocalFlag) Bivariant else info.typeSymbol.variance
+ override def variance = if (isLocalToThis) Bivariant else info.typeSymbol.variance
override def isContravariant = variance.isContravariant
override def isCovariant = variance.isCovariant
final override def isAliasType = true
@@ -3105,7 +3109,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
*/
override def isLocalClass = (
isAnonOrRefinementClass
- || isLocal
+ || isLocalToBlock
|| !isTopLevel && owner.isLocalClass
)