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 | |
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.
18 files changed, 51 insertions, 49 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index e3d2bf14a0..0a753f157c 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2234,7 +2234,7 @@ self => } else { // XX-METHOD-INFER accept(COLON) if (in.token == ARROW) { - if (owner.isTypeName && !mods.hasLocalFlag) + if (owner.isTypeName && !mods.isLocalToThis) syntaxError( in.offset, (if (mods.isMutable) "`var'" else "`val'") + diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 55f45257dc..592c5497b5 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -99,7 +99,7 @@ abstract class Pickler extends SubComponent { * added to fix that bug, but there may be a better way. */ private def localizedOwner(sym: Symbol) = - if (isLocal(sym) && !isRootSym(sym) && !isLocal(sym.owner)) + if (isLocalToPickle(sym) && !isRootSym(sym) && !isLocalToPickle(sym.owner)) // don't use a class as the localized owner for type parameters that are not owned by a class: those are not instantiated by asSeenFrom // however, they would suddenly be considered by asSeenFrom if their localized owner became a class (causing the crashes of #4079, #2741) (if ((sym.isTypeParameter || sym.isValueParameter) && !sym.owner.isClass) nonClassRoot @@ -110,14 +110,14 @@ abstract class Pickler extends SubComponent { * anyway? This is the case if symbol is a refinement class, * an existentially bound variable, or a higher-order type parameter. */ - private def isLocal(sym: Symbol): Boolean = (sym != NoSymbol) && !sym.isPackageClass && ( + private def isLocalToPickle(sym: Symbol): Boolean = (sym != NoSymbol) && !sym.isPackageClass && ( isRootSym(sym) || sym.isRefinementClass || sym.isAbstractType && sym.hasFlag(EXISTENTIAL) // existential param || sym.isParameter - || isLocal(sym.owner) + || isLocalToPickle(sym.owner) ) - private def isExternalSymbol(sym: Symbol): Boolean = (sym != NoSymbol) && !isLocal(sym) + private def isExternalSymbol(sym: Symbol): Boolean = (sym != NoSymbol) && !isLocalToPickle(sym) // Phase 1 methods: Populate entries/index ------------------------------------ @@ -174,7 +174,7 @@ abstract class Pickler extends SubComponent { val sym = deskolemize(sym0) if (putEntry(sym)) { - if (isLocal(sym)) { + if (isLocalToPickle(sym)) { putEntry(sym.name) putSymbol(sym.owner) putSymbol(sym.privateWithin) @@ -428,7 +428,7 @@ abstract class Pickler extends SubComponent { } def writeSymbolBody(sym: Symbol) { if (sym ne NoSymbol) { - if (isLocal(sym)) + if (isLocalToPickle(sym)) writeLocalSymbolBody(sym) else writeExtSymbolBody(sym) diff --git a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala index d81a5d5755..818d0767b9 100644 --- a/src/compiler/scala/tools/nsc/transform/Delambdafy.scala +++ b/src/compiler/scala/tools/nsc/transform/Delambdafy.scala @@ -393,7 +393,7 @@ abstract class Delambdafy extends Transform with TypingTransformers with ast.Tre declared += tree.symbol case Ident(_) => val sym = tree.symbol - if ((sym != NoSymbol) && sym.isLocal && sym.isTerm && !sym.isMethod && !declared.contains(sym)) freeVars += sym + if ((sym != NoSymbol) && sym.isLocalToBlock && sym.isTerm && !sym.isMethod && !declared.contains(sym)) freeVars += sym case _ => } super.traverse(tree) diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala index b2e071579e..0447e23e9e 100644 --- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala +++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala @@ -206,7 +206,7 @@ abstract class ExplicitOuter extends InfoTransform // On the other hand, mixing in the trait into a separately compiled // class needs to have a common naming scheme, independently of whether // the field was accessed from an inner class or not. See #2946 - if (sym.owner.isTrait && sym.hasLocalFlag && + if (sym.owner.isTrait && sym.isLocalToThis && (sym.getter(sym.owner.toInterface) == NoSymbol)) sym.makeNotPrivate(sym.owner) tp 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 diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index c59b726076..fea49be900 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -716,7 +716,6 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { enterMember(specVal) // create accessors - // debuglog("m: " + m + " isLocal: " + nme.isLocalName(m.name) + " specVal: " + specVal.name + " isLocal: " + nme.isLocalName(specVal.name)) if (nme.isLocalName(m.name)) { val specGetter = mkAccessor(specVal, specVal.getterName) setInfo MethodType(Nil, specVal.info) diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index e7ea686bc8..8a7d30235f 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -412,7 +412,7 @@ abstract class UnCurry extends InfoTransform val sym = tree.symbol // true if the taget is a lambda body that's been lifted into a method - def isLiftedLambdaBody(target: Tree) = target.symbol.isLocal && target.symbol.isArtifact && target.symbol.name.containsName(nme.ANON_FUN_NAME) + def isLiftedLambdaBody(target: Tree) = target.symbol.isLocalToBlock && target.symbol.isArtifact && target.symbol.name.containsName(nme.ANON_FUN_NAME) val result = ( // TODO - settings.noassertions.value temporarily retained to avoid diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index c065fb54b7..a66925b948 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -516,7 +516,7 @@ trait Contexts { self: Analyzer => argContext.scope enter e.sym } } - if (c.isLocal && !c.owner.isLocalDummy) { + if (c.owner.isTerm && !c.owner.isLocalDummy) { enterElems(c.outer) enterLocalElems(c.scope.elems) } @@ -589,9 +589,6 @@ trait Contexts { self: Analyzer => else if (bufferErrors) reportBuffer += (pos -> msg) } - /** Is the owning symbol of this context a term? */ - final def isLocal: Boolean = owner.isTerm - // nextOuter determines which context is searched next for implicits // (after `this`, which contributes `newImplicits` below.) In // most cases, it is simply the outer context: if we're owned by @@ -714,7 +711,7 @@ trait Contexts { self: Analyzer => ( (ab.isTerm || ab == rootMirror.RootClass) || (accessWithin(ab) || accessWithinLinked(ab)) && - ( !sym.hasLocalFlag + ( !sym.isLocalToThis || sym.owner.isImplClass // allow private local accesses to impl classes || sym.isProtected && isSubThisType(pre, sym.owner) || pre =:= sym.owner.thisType 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 diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 06796eca8e..06f9667ef0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -224,7 +224,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT if (settings.lint) { if (sym.isPrivateLocal && sym.paramss.isEmpty) { qual.symbol.ancestors foreach { parent => - parent.info.decls filterNot (x => x.isPrivate || x.hasLocalFlag) foreach { m2 => + parent.info.decls filterNot (x => x.isPrivate || x.isLocalToThis) foreach { m2 => if (sym.name == m2.name && m2.isGetter && m2.accessed.isMutable) { unit.warning(sel.pos, sym.accessString + " " + sym.fullLocationString + " shadows mutable " + m2.name diff --git a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala index fd8f9bebba..a2f52e1905 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TreeCheckers.scala @@ -376,7 +376,7 @@ abstract class TreeCheckers extends Analyzer { def isOk(sym: Symbol) = treeSym hasTransOwner sym.enclosingSuchThat(x => !x.isTypeParameterOrSkolem) // account for higher order type params def isEligible(sym: Symbol) = (sym ne NoSymbol) && ( sym.isTypeParameter - || sym.isLocal + || sym.isLocalToBlock ) val referencedSymbols = (treeSym :: referencesInType(treeInfo)).distinct filter (sym => isEligible(sym) && !isOk(sym)) def mk[T](what: String, x: T, str: T => String = (x: T) => "" + x): ((Any, String)) = diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index b801b644fb..4e3e00b66a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -452,10 +452,10 @@ trait TypeDiagnostics { val treeTypes = mutable.Set[Type]() def defnSymbols = defnTrees.toList map (_.symbol) - def localVars = defnSymbols filter (t => t.isLocal && t.isVar) + def localVars = defnSymbols filter (t => t.isLocalToBlock && t.isVar) def qualifiesTerm(sym: Symbol) = ( - (sym.isModule || sym.isMethod || sym.isPrivateLocal || sym.isLocal) + (sym.isModule || sym.isMethod || sym.isPrivateLocal || sym.isLocalToBlock) && !nme.isLocalName(sym.name) && !sym.isParameter && !sym.isParamAccessor // could improve this, but it's a pain @@ -499,12 +499,12 @@ trait TypeDiagnostics { def isUnusedType(m: Symbol): Boolean = ( m.isType && !m.isTypeParameterOrSkolem // would be nice to improve this - && (m.isPrivate || m.isLocal) + && (m.isPrivate || m.isLocalToBlock) && !(treeTypes.exists(tp => tp exists (t => t.typeSymbolDirect == m))) ) def isUnusedTerm(m: Symbol): Boolean = ( (m.isTerm) - && (m.isPrivate || m.isLocal) + && (m.isPrivate || m.isLocalToBlock) && !targets(m) && !(m.name == nme.WILDCARD) // e.g. val _ = foo && !ignoreNames(m.name.toTermName) // serialization methods diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 1a53fef4aa..e13304c6ba 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -389,7 +389,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (sym.isPrivate && !sym.hasFlag(SYNTHETIC_PRIVATE)) { var o = owner while (o != NoSymbol && o != sym.owner && o != sym.owner.linkedClassOfClass && - !o.isLocal && !o.isPrivate && + !o.isLocalToBlock && !o.isPrivate && !o.privateWithin.hasTransOwner(sym.owner)) o = o.owner if (o == sym.owner || o == sym.owner.linkedClassOfClass) @@ -3037,7 +3037,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper /* 'accessor' and 'accessed' are so similar it becomes very difficult to * follow the logic, so I renamed one to something distinct. */ - def accesses(looker: Symbol, accessed: Symbol) = accessed.hasLocalFlag && ( + def accesses(looker: Symbol, accessed: Symbol) = accessed.isLocalToThis && ( (accessed.isParamAccessor) || (looker.hasAccessorFlag && !accessed.hasAccessorFlag && accessed.isPrivate) ) diff --git a/src/reflect/scala/reflect/internal/HasFlags.scala b/src/reflect/scala/reflect/internal/HasFlags.scala index 1131c94da0..8915524bde 100644 --- a/src/reflect/scala/reflect/internal/HasFlags.scala +++ b/src/reflect/scala/reflect/internal/HasFlags.scala @@ -83,7 +83,9 @@ trait HasFlags { def hasAccessorFlag = hasFlag(ACCESSOR) def hasDefault = hasFlag(DEFAULTPARAM) && hasFlag(METHOD | PARAM) // Second condition disambiguates with TRAIT def hasEnumFlag = hasFlag(ENUM) + @deprecated("Use isLocalToThis instead", "2.11.0") def hasLocalFlag = hasFlag(LOCAL) + def isLocalToThis = hasFlag(LOCAL) def hasModuleFlag = hasFlag(MODULE) def hasPackageFlag = hasFlag(PACKAGE) def hasStableFlag = hasFlag(STABLE) 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 ) diff --git a/src/reflect/scala/reflect/internal/Trees.scala b/src/reflect/scala/reflect/internal/Trees.scala index 4a518f6c56..125146d9a2 100644 --- a/src/reflect/scala/reflect/internal/Trees.scala +++ b/src/reflect/scala/reflect/internal/Trees.scala @@ -590,7 +590,7 @@ trait Trees extends api.Trees { def TypeTree(tp: Type): TypeTree = TypeTree() setType tp private def TypeTreeMemberType(sym: Symbol): TypeTree = { // Needed for pos/t4970*.scala. See SI-7853 - val resType = (if (sym.isLocal) sym.tpe else (sym.owner.thisType memberType sym)).finalResultType + val resType = (if (sym.isLocalToBlock) sym.tpe else (sym.owner.thisType memberType sym)).finalResultType atPos(sym.pos.focus)(TypeTree(resType)) } diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index a7cac5254c..ea301fba1c 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -33,7 +33,7 @@ trait Variances { /** Is every symbol in the owner chain between `site` and the owner of `sym` * either a term symbol or private[this]? If not, add `sym` to the set of * esacped locals. - * @pre sym.hasLocalFlag + * @pre sym.isLocalToThis */ @tailrec final def checkForEscape(sym: Symbol, site: Symbol) { if (site == sym.owner || site == sym.owner.moduleClass || site.isPackage) () // done @@ -53,8 +53,8 @@ trait Variances { // return Bivariant if `sym` is local to a term // or is private[this] or protected[this] def isLocalOnly(sym: Symbol) = !sym.owner.isClass || ( - sym.isTerm - && (sym.hasLocalFlag || sym.isSuperAccessor) // super accessors are implicitly local #4345 + sym.isTerm // ?? shouldn't this be sym.owner.isTerm according to the comments above? + && (sym.isLocalToThis || sym.isSuperAccessor) // super accessors are implicitly local #4345 && !escapedLocals(sym) ) @@ -143,7 +143,7 @@ trait Variances { // Or constructors, or case class factory or extractor. def skip = ( sym == NoSymbol - || sym.hasLocalFlag + || sym.isLocalToThis || sym.owner.isConstructor || sym.owner.isCaseApplyOrUnapply ) diff --git a/src/reflect/scala/reflect/internal/transform/Erasure.scala b/src/reflect/scala/reflect/internal/transform/Erasure.scala index 786ff2210c..d5b5967145 100644 --- a/src/reflect/scala/reflect/internal/transform/Erasure.scala +++ b/src/reflect/scala/reflect/internal/transform/Erasure.scala @@ -74,7 +74,7 @@ trait Erasure { // // This requires that cls.isClass. protected def rebindInnerClass(pre: Type, cls: Symbol): Type = - if (cls.isTopLevel || cls.isLocal) pre else cls.owner.tpe_* + if (cls.isTopLevel || cls.isLocalToBlock) pre else cls.owner.tpe_* /** The type of the argument of a value class reference after erasure * This method needs to be called at a phase no later than erasurephase |