summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/internal/Flags.scala75
-rw-r--r--src/compiler/scala/reflect/internal/HasFlags.scala72
-rw-r--r--src/compiler/scala/reflect/internal/SymbolFlags.scala110
-rw-r--r--src/compiler/scala/reflect/internal/Symbols.scala78
-rw-r--r--src/compiler/scala/reflect/internal/Trees.scala9
-rw-r--r--src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala2
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/DocComments.scala7
-rw-r--r--src/compiler/scala/tools/nsc/transform/AddInterfaces.scala5
-rw-r--r--src/compiler/scala/tools/nsc/transform/Mixin.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala2
-rw-r--r--test/files/run/compiler-asSeenFrom.check36
12 files changed, 216 insertions, 191 deletions
diff --git a/src/compiler/scala/reflect/internal/Flags.scala b/src/compiler/scala/reflect/internal/Flags.scala
index 38f9ec6669..ce459bdd06 100644
--- a/src/compiler/scala/reflect/internal/Flags.scala
+++ b/src/compiler/scala/reflect/internal/Flags.scala
@@ -121,9 +121,9 @@ class ModifierFlags {
// Overridden.
def flagToString(flag: Long): String = ""
- final val PrivateLocal: Long = PRIVATE | LOCAL
- final val ProtectedLocal: Long = PROTECTED | LOCAL
- final val AccessFlags: Long = PRIVATE | PROTECTED | LOCAL
+ final val PrivateLocal = PRIVATE | LOCAL
+ final val ProtectedLocal = PROTECTED | LOCAL
+ final val AccessFlags = PRIVATE | PROTECTED | LOCAL
}
object ModifierFlags extends ModifierFlags
@@ -216,22 +216,22 @@ class Flags extends ModifierFlags {
/** These flags can be set when class or module symbol is first created.
* They are the only flags to survive a call to resetFlags().
*/
- final val TopLevelCreationFlags: Long =
+ final val TopLevelCreationFlags =
MODULE | PACKAGE | FINAL | JAVA
// TODO - there's no call to slap four flags onto every package.
- final val PackageFlags: Long = TopLevelCreationFlags
+ final val PackageFlags = TopLevelCreationFlags
// FINAL not included here due to possibility of object overriding.
// In fact, FINAL should not be attached regardless. We should be able
// to reconstruct whether an object was marked final in source.
- final val ModuleFlags: Long = MODULE
+ final val ModuleFlags = MODULE
/** These modifiers can be set explicitly in source programs. This is
* used only as the basis for the default flag mask (which ones to display
* when printing a normal message.)
*/
- final val ExplicitFlags: Long =
+ final val ExplicitFlags =
PRIVATE | PROTECTED | ABSTRACT | FINAL | SEALED |
OVERRIDE | CASE | IMPLICIT | ABSOVERRIDE | LAZY
@@ -240,7 +240,7 @@ class Flags extends ModifierFlags {
final val BridgeAndPrivateFlags = BridgeFlags | PRIVATE
/** These modifiers appear in TreePrinter output. */
- final val PrintableFlags: Long =
+ final val PrintableFlags =
ExplicitFlags | BridgeFlags | LOCAL | SYNTHETIC | STABLE | CASEACCESSOR | MACRO |
ACCESSOR | SUPERACCESSOR | PARAMACCESSOR | STATIC | SPECIALIZED | SYNCHRONIZED
@@ -248,7 +248,7 @@ class Flags extends ModifierFlags {
* from Modifiers. Others which may be applied at creation time are:
* PRIVATE, LOCAL.
*/
- final val FieldFlags: Long =
+ final val FieldFlags =
MUTABLE | CASEACCESSOR | PARAMACCESSOR | STATIC | FINAL | PRESUPER | LAZY
/** Masks for getters and setters, where the flags are derived from those
@@ -262,24 +262,23 @@ class Flags extends ModifierFlags {
* flags from the method with the default. Other flags applied at creation
* time are SYNTHETIC, DEFAULTPARAM, and possibly OVERRIDE.
*/
- final val DefaultGetterFlags: Long =
- PRIVATE | PROTECTED | FINAL
+ final val DefaultGetterFlags = PRIVATE | PROTECTED | FINAL
/** When a symbol for a method parameter is created, only these flags survive
* from Modifiers. Others which may be applied at creation time are:
* SYNTHETIC.
*/
- final val ValueParameterFlags: Long = BYNAMEPARAM | IMPLICIT | DEFAULTPARAM
- final val BeanPropertyFlags = DEFERRED | OVERRIDE | STATIC
- final val VarianceFlags = COVARIANT | CONTRAVARIANT
+ final val ValueParameterFlags = BYNAMEPARAM | IMPLICIT | DEFAULTPARAM
+ final val BeanPropertyFlags = DEFERRED | OVERRIDE | STATIC
+ final val VarianceFlags = COVARIANT | CONTRAVARIANT
/** These appear to be flags which should be transferred from owner symbol
* to a newly created constructor symbol.
*/
- final val ConstrFlags: Long = JAVA
+ final val ConstrFlags = JAVA
/** Module flags inherited by their module-class */
- final val ModuleToClassFlags: Long = AccessFlags | TopLevelCreationFlags | CASE | SYNTHETIC
+ final val ModuleToClassFlags = AccessFlags | TopLevelCreationFlags | CASE | SYNTHETIC
def getterFlags(fieldFlags: Long): Long = ACCESSOR + (
if ((fieldFlags & MUTABLE) != 0) fieldFlags & ~MUTABLE & ~PRESUPER
@@ -309,7 +308,7 @@ class Flags extends ModifierFlags {
private final val PKL_MASK = 0x00000FFF
- final val PickledFlags: Long = 0xFFFFFFFFL
+ final val PickledFlags = 0xFFFFFFFFL
private def rawPickledCorrespondence = Array(
(IMPLICIT, IMPLICIT_PKL),
@@ -421,8 +420,8 @@ class Flags extends ModifierFlags {
case 0x8000000000000000L => "" // (1L << 63)
case _ => ""
}
-
- def accessString(flags: Long, privateWithin: String)= (
+
+ private def accessString(flags: Long, privateWithin: String)= (
if (privateWithin == "") {
if ((flags & PrivateLocal) == PrivateLocal) "private[this]"
else if ((flags & ProtectedLocal) == ProtectedLocal) "protected[this]"
@@ -433,37 +432,16 @@ class Flags extends ModifierFlags {
else if ((flags & PROTECTED) != 0) "protected[" + privateWithin + "]"
else "private[" + privateWithin + "]"
)
- def nonAccessString(flags0: Long)(flagStringFn: Long => String): String = {
- val flags = flags0 & ~AccessFlags
- // Fast path for common case
- if (flags == 0L) "" else {
- var sb: StringBuilder = null
- var i = 0
- while (i <= MaxBitPosition) {
- val mask = rawFlagPickledOrder(i)
- if ((flags & mask) != 0L) {
- val s = flagStringFn(mask)
- if (s.length > 0) {
- if (sb eq null) sb = new StringBuilder append s
- else if (sb.length == 0) sb append s
- else sb append " " append s
- }
- }
- i += 1
- }
- if (sb eq null) "" else sb.toString
- }
- }
-
+
+ @deprecated("Use flagString on the flag-carrying member", "2.10.0")
def flagsToString(flags: Long, privateWithin: String): String = {
- val access = accessString(flags, privateWithin)
+ val access = accessString(flags, privateWithin)
val nonAccess = flagsToString(flags & ~AccessFlags)
+
List(nonAccess, access) filterNot (_ == "") mkString " "
}
- // List of the raw flags, in pickled order
- protected final val MaxBitPosition = 62
-
+ @deprecated("Use flagString on the flag-carrying member", "2.10.0")
def flagsToString(flags: Long): String = {
// Fast path for common case
if (flags == 0L) "" else {
@@ -491,13 +469,16 @@ class Flags extends ModifierFlags {
def pickledToRawFlags(pflags: Long): Long =
(pflags & ~PKL_MASK) | p2r(pflags.toInt & PKL_MASK)
- protected final val pickledListOrder: List[Long] = {
+ // List of the raw flags, in pickled order
+ final val MaxBitPosition = 62
+
+ final val pickledListOrder: List[Long] = {
val all = 0 to MaxBitPosition map (1L << _)
val front = rawFlags map (_.toLong)
front.toList ++ (all filterNot (front contains _))
}
- protected final val rawFlagPickledOrder: Array[Long] = pickledListOrder.toArray
+ final val rawFlagPickledOrder: Array[Long] = pickledListOrder.toArray
def flagOfModifier(mod: Modifier): Long = mod match {
case Modifier.`protected` => PROTECTED
diff --git a/src/compiler/scala/reflect/internal/HasFlags.scala b/src/compiler/scala/reflect/internal/HasFlags.scala
index 2f574b6bfa..348f81c51d 100644
--- a/src/compiler/scala/reflect/internal/HasFlags.scala
+++ b/src/compiler/scala/reflect/internal/HasFlags.scala
@@ -7,7 +7,6 @@ import Flags._
* with Trees) and Symbol.
*/
trait HasFlags {
- type FlagsType
type AccessBoundaryType
type AnnotationType
@@ -16,12 +15,7 @@ trait HasFlags {
* flag methods through accessors and disallow raw flag manipulation.
* And after that, perhaps, on some magical day: a typesafe enumeration.
*/
- protected def flags: FlagsType
-
- /** The printable representation of this entity's flags and access boundary,
- * restricted to flags in the given mask.
- */
- def hasFlagsToString(mask: FlagsType): String
+ protected def flags: Long
/** Access level encoding: there are three scala flags (PRIVATE, PROTECTED,
* and LOCAL) which combine with value privateWithin (the "foo" in private[foo])
@@ -67,6 +61,23 @@ trait HasFlags {
*/
def hasNoFlags(mask: Long): Boolean = !hasFlag(mask)
+ /** The printable representation of this entity's flags and access boundary,
+ * restricted to flags in the given mask.
+ */
+ def flagString: String = flagString(flagMask)
+ def flagString(mask: Long): String = calculateFlagString(flags & mask)
+
+ /** The default mask determining which flags to display.
+ */
+ def flagMask: Long = AllFlags
+
+ /** The string representation of a single bit, seen from this
+ * flag carrying entity.
+ */
+ def resolveOverloadedFlag(flag: Long): String = Flags.flagToString(flag)
+
+ def privateWithinString = if (hasAccessBoundary) privateWithin.toString else ""
+
protected def isSetting(f: Long, mask: Long) = !hasFlag(f) && ((mask & f) != 0L)
protected def isClearing(f: Long, mask: Long) = hasFlag(f) && ((mask & f) != 0L)
@@ -129,6 +140,49 @@ trait HasFlags {
// Name
def isJavaDefined = hasFlag(JAVA)
+ def flagBitsToString(bits: Long): String = {
+ // Fast path for common case
+ if (bits == 0L) "" else {
+ var sb: StringBuilder = null
+ var i = 0
+ while (i <= MaxBitPosition) {
+ val flag = Flags.rawFlagPickledOrder(i)
+ if ((bits & flag) != 0L) {
+ val s = resolveOverloadedFlag(flag)
+ if (s.length > 0) {
+ if (sb eq null) sb = new StringBuilder append s
+ else if (sb.length == 0) sb append s
+ else sb append " " append s
+ }
+ }
+ i += 1
+ }
+ if (sb eq null) "" else sb.toString
+ }
+ }
+
+ def accessString: String = {
+ val pw = privateWithinString
+
+ if (pw == "") {
+ if (hasAllFlags(PrivateLocal)) "private[this]"
+ else if (hasAllFlags(ProtectedLocal)) "protected[this]"
+ else if (hasFlag(PRIVATE)) "private"
+ else if (hasFlag(PROTECTED)) "protected"
+ else ""
+ }
+ else if (hasFlag(PROTECTED)) "protected[" + pw + "]"
+ else "private[" + pw + "]"
+ }
+ protected def calculateFlagString(basis: Long): String = {
+ val access = accessString
+ val nonAccess = flagBitsToString(basis & ~AccessFlags)
+
+ if (access == "") nonAccess
+ else if (nonAccess == "") access
+ else nonAccess + " " + access
+ }
+
// Backward compat section
@deprecated( "Use isTrait", "2.10.0")
def hasTraitFlag = hasFlag(TRAIT)
@@ -138,4 +192,8 @@ trait HasFlags {
def isAbstract = hasFlag(ABSTRACT)
@deprecated("Use isValueParameter or isTypeParameter", "2.10.0")
def isParameter = hasFlag(PARAM)
+ @deprecated("Use flagString", "2.10.0")
+ def defaultFlagString = flagString
+ @deprecated("Use flagString(mask)", "2.10.0")
+ def hasFlagsToString(mask: Long): String = flagString(mask)
}
diff --git a/src/compiler/scala/reflect/internal/SymbolFlags.scala b/src/compiler/scala/reflect/internal/SymbolFlags.scala
index 0b49ee2505..0c620f8346 100644
--- a/src/compiler/scala/reflect/internal/SymbolFlags.scala
+++ b/src/compiler/scala/reflect/internal/SymbolFlags.scala
@@ -20,9 +20,7 @@ trait SymbolFlags {
/** Not mixed in under normal conditions; a powerful debugging aid.
*/
- trait FlagVerifier extends SymbolFlagLogic {
- this: Symbol =>
-
+ trait FlagVerifier extends Symbol {
private def assert0(cond: Boolean, message: => Any) {
if (!cond) {
Console.err.println("[flag verification failure]\n%s\n%s\n".format(atPhaseStackMessage, message))
@@ -71,29 +69,29 @@ trait SymbolFlags {
assert0(!hasRaw, symbolCreationString + "\n never=%s, what=%s".format(flagsToString(neverHasFlags), what))
}
}
- override def initFlags(mask: Long): this.type = {
+ abstract override def initFlags(mask: Long): this.type = {
super.initFlags(mask)
verifyFlags("initFlags(" + flagsToString(mask) + ")")
this
}
- override def setFlag(mask: Long): this.type = {
+ abstract override def setFlag(mask: Long): this.type = {
verifyChange(true, mask, rawflags)
super.setFlag(mask)
verifyFlags("setFlag(" + flagsToString(mask) + ")")
this
}
- override def resetFlag(mask: Long): this.type = {
+ abstract override def resetFlag(mask: Long): this.type = {
verifyChange(false, mask, rawflags)
super.resetFlag(mask)
verifyFlags("resetFlag(" + flagsToString(mask) + ")")
this
}
- override def flags_=(fs: Long) {
+ abstract override def flags_=(fs: Long) {
if ((fs & ~rawflags) != 0)
verifyChange(true, fs & ~rawflags, rawflags)
if ((rawflags & ~fs) != 0)
verifyChange(false, rawflags & ~fs, rawflags)
-
+
super.flags_=(fs)
verifyFlags("flags_=(" + flagsToString(fs) + ")")
}
@@ -113,58 +111,25 @@ trait SymbolFlags {
trait SymbolFlagLogic {
this: Symbol =>
- protected def alwaysHasFlags: Long = 0L
- protected def neverHasFlags: Long = METHOD | MODULE
-
- def flagStringFn(flag: Long): String = {
- val res = flag match {
- // "<bynameparam/captured/covariant>"
- case BYNAMEPARAM =>
- if (this.isValueParameter) "<bynameparam>"
- else if (this.isTypeParameter) "<covariant>"
- else "<captured>"
- // "<contravariant/inconstructor/label>"
- case CONTRAVARIANT =>
- if (this.isLabel) "<label>"
- else if (this.isTypeParameter) "<contravariant>"
- else "<inconstructor>"
- // "<defaultparam/trait>"
- case DEFAULTPARAM =>
- if (this.isTerm && (this hasFlag PARAM)) "<defaultparam>"
- else "<trait>"
- // "<existential/mixedin>"
- case EXISTENTIAL =>
- if (this.isType) "<existential>"
- else "<mixedin>"
- // "<implclass/presuper>"
- case IMPLCLASS =>
- if (this.isClass) "<implclass>"
- else "<presuper>"
- case _ => ""
- }
- if (res == "") Flags.flagToString(flag)
- else res + ":overloaded-flag"
- }
+ // Forced for performance reasons to define all the flag manipulation
+ // methods alongside the field being manipulated.
+ def getFlag(mask: Long): Long
+ def hasFlag(mask: Long): Boolean
+ def hasAllFlags(mask: Long): Boolean
+ def setFlag(mask: Long): this.type
+ def resetFlag(mask: Long): this.type
+ def initFlags(mask: Long): this.type
+ def resetFlags(): Unit
- private def calculateFlagString(basis: Long): String = {
- val nonAccess = nonAccessString(basis)(flagStringFn)
- val access = Flags.accessString(basis, pwString)
+ protected def resolveOverloadedFlag(flag: Long): String
+ protected def calculateFlagString(basis: Long): String
- ojoin(nonAccess, access)
- }
+ protected def alwaysHasFlags: Long = 0L
+ protected def neverHasFlags: Long = METHOD | MODULE
- def flagString(mask: Long): String = calculateFlagString(flags & mask)
- def flagString: String = flagString(defaultFlagMask)
def rawFlagString(mask: Long): String = calculateFlagString(rawflags & mask)
- def rawFlagString: String = rawFlagString(defaultFlagMask)
- def flaggedString(mask: Long): String = flagString(mask)
- def flaggedString: String = flaggedString(defaultFlagMask)
-
- def accessString = calculateFlagString(flags & AccessFlags)
- def debugFlagString = flaggedString(AllFlags)
- def defaultFlagString = flaggedString(defaultFlagMask)
-
- def hasFlagsToString(mask: Long) = flagString(mask)
+ def rawFlagString: String = rawFlagString(flagMask)
+ def debugFlagString: String = flagString(AllFlags)
/** String representation of symbol's variance */
def varianceString: String =
@@ -172,7 +137,7 @@ trait SymbolFlags {
else if (variance == -1) "-"
else ""
- def defaultFlagMask =
+ override def flagMask =
if (settings.debug.value && !isAbstractType) AllFlags
else if (owner.isRefinementClass) ExplicitFlags & ~OVERRIDE
else ExplicitFlags
@@ -182,37 +147,6 @@ trait SymbolFlags {
if (isGADTSkolem) " (this is a GADT skolem)"
else ""
- private def pwString = if (hasAccessBoundary) privateWithin.toString else ""
- private var _rawflags: FlagsType = 0L
- protected def rawflags_=(x: FlagsType) { _rawflags = x }
- def rawflags = _rawflags
-
- final def flags: Long = {
- val fs = rawflags & phase.flagMask
- (fs | ((fs & LateFlags) >>> LateShift)) & ~(fs >>> AntiShift)
- }
- def flags_=(fs: Long) = rawflags = fs
-
- /** Set the symbol's flags to the given value, asserting
- * that the previous value was 0.
- */
- def initFlags(mask: Long): this.type = {
- assert(rawflags == 0L, symbolCreationString)
- rawflags = mask
- this
- }
- def reinitFlags(mask: Long): this.type = {
- rawflags = mask
- this
- }
- def setFlag(mask: Long): this.type = { rawflags |= mask ; this }
- def resetFlag(mask: Long): this.type = { rawflags &= ~mask ; this }
- def resetFlags() { rawflags &= (TopLevelCreationFlags | alwaysHasFlags) }
-
- def getFlag(mask: Long): Long
- def hasFlag(mask: Long): Boolean
- def hasAllFlags(mask: Long): Boolean
-
/** If the given flag is set on this symbol, also set the corresponding
* notFLAG. For instance if flag is PRIVATE, the notPRIVATE flag will
* be set if PRIVATE is currently set.
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala
index dc72ac2338..6666a49491 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/compiler/scala/reflect/internal/Symbols.scala
@@ -151,18 +151,19 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
with HasFlags
with SymbolFlagLogic
with SymbolCreator
- // with FlagVerifier
+ // with FlagVerifier // DEBUG
with Annotatable[Symbol] {
- type FlagsType = Long
type AccessBoundaryType = Symbol
type AnnotationType = AnnotationInfo
private[this] var _rawowner = initOwner // Syncnote: need not be protected, as only assignment happens in owner_=, which is not exposed to api
private[this] var _rawname = initName
+ private[this] var _rawflags: Long = _
def rawowner = _rawowner
- def rawname = _rawname
+ def rawname = _rawname
+ def rawflags = _rawflags
private var rawpos = initPos
@@ -407,7 +408,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// True if the symbol is locked but still below the allowed recursion depth.
// False otherwise
private[scala] def lockOK: Boolean = {
- ((rawflags & LOCKED) == 0L) ||
+ ((_rawflags & LOCKED) == 0L) ||
((settings.Yrecursion.value != 0) &&
(recursionTable get this match {
case Some(n) => (n <= settings.Yrecursion.value)
@@ -416,7 +417,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// Lock a symbol, using the handler if the recursion depth becomes too great.
private[scala] def lock(handler: => Unit): Boolean = {
- if ((rawflags & LOCKED) != 0L) {
+ if ((_rawflags & LOCKED) != 0L) {
if (settings.Yrecursion.value != 0) {
recursionTable get this match {
case Some(n) =>
@@ -433,7 +434,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
}
} else { handler; false }
} else {
- rawflags |= LOCKED
+ _rawflags |= LOCKED
true
// activeLocks += 1
// lockedSyms += this
@@ -442,10 +443,10 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// Unlock a symbol
private[scala] def unlock() = {
- if ((rawflags & LOCKED) != 0L) {
+ if ((_rawflags & LOCKED) != 0L) {
// activeLocks -= 1
// lockedSyms -= this
- rawflags &= ~LOCKED
+ _rawflags &= ~LOCKED
if (settings.Yrecursion.value != 0)
recursionTable -= this
}
@@ -562,6 +563,32 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
@inline final override def hasFlag(mask: Long): Boolean = (flags & mask) != 0
/** Does symbol have ALL the flags in `mask` set? */
@inline final override def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask
+
+ override def setFlag(mask: Long): this.type = { _rawflags |= mask ; this }
+ override def resetFlag(mask: Long): this.type = { _rawflags &= ~mask ; this }
+ override def resetFlags() { rawflags &= (TopLevelCreationFlags | alwaysHasFlags) }
+
+ /** Default implementation calls the generic string function, which
+ * will print overloaded flags as <flag1/flag2/flag3>. Subclasses
+ * of Symbol refine.
+ */
+ override def resolveOverloadedFlag(flag: Long): String = Flags.flagToString(flag)
+
+ /** Set the symbol's flags to the given value, asserting
+ * that the previous value was 0.
+ */
+ override def initFlags(mask: Long): this.type = {
+ assert(rawflags == 0L, symbolCreationString)
+ _rawflags = mask
+ this
+ }
+
+ final def flags: Long = {
+ val fs = _rawflags & phase.flagMask
+ (fs | ((fs & LateFlags) >>> LateShift)) & ~(fs >>> AntiShift)
+ }
+ def flags_=(fs: Long) = _rawflags = fs
+ def rawflags_=(x: Long) { _rawflags = x }
/** Term symbols with the exception of static parts of Java classes and packages.
*/
@@ -1067,13 +1094,13 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
val tp = infos.info
//if (settings.debug.value) System.out.println("completing " + this.rawname + tp.getClass());//debug
- if ((rawflags & LOCKED) != 0L) { // rolled out once for performance
+ if ((_rawflags & LOCKED) != 0L) { // rolled out once for performance
lock {
setInfo(ErrorType)
throw CyclicReference(this, tp)
}
} else {
- rawflags |= LOCKED
+ _rawflags |= LOCKED
// activeLocks += 1
// lockedSyms += this
}
@@ -1474,7 +1501,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
/** A clone of this symbol, but with given owner. */
final def cloneSymbol(newOwner: Symbol): Symbol =
- cloneSymbol(newOwner, this.rawflags)
+ cloneSymbol(newOwner, _rawflags)
final def cloneSymbol(newOwner: Symbol, newFlags: Long): Symbol =
cloneSymbol(newOwner, newFlags, nme.NO_NAME)
final def cloneSymbol(newOwner: Symbol, newFlags: Long, newName: Name): Symbol = {
@@ -2140,7 +2167,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
def debugLocationString = fullLocationString + " " + debugFlagString
private def defStringCompose(infoString: String) = compose(
- defaultFlagString,
+ flagString,
keyString,
varianceString + nameString + infoString + flagsExplanationString
)
@@ -2189,6 +2216,17 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override def isPackageObject = isModule && (name == nme.PACKAGE)
+ // The name in comments is what it is being disambiguated from.
+ // TODO - rescue CAPTURED from BYNAMEPARAM so we can see all the names.
+ override def resolveOverloadedFlag(flag: Long) = flag match {
+ case DEFAULTPARAM => "<defaultparam>" // TRAIT
+ case MIXEDIN => "<mixedin>" // EXISTENTIAL
+ case LABEL => "<label>" // CONTRAVARIANT / INCONSTRUCTOR
+ case PRESUPER => "<presuper>" // IMPLCLASS
+ case BYNAMEPARAM => if (this.isValueParameter) "<bynameparam>" else "<captured>" // COVARIANT
+ case _ => super.resolveOverloadedFlag(flag)
+ }
+
def referenced: Symbol = _referenced
def referenced_=(x: Symbol) { _referenced = x }
@@ -2380,6 +2418,14 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
final override def isType = true
override def isNonClassType = true
+
+ override def resolveOverloadedFlag(flag: Long) = flag match {
+ case TRAIT => "<trait>" // DEFAULTPARAM
+ case EXISTENTIAL => "<existential>" // MIXEDIN
+ case COVARIANT => "<covariant>" // BYNAMEPARAM / CAPTURED
+ case CONTRAVARIANT => "<contravariant>" // LABEL / INCONSTRUCTOR (overridden again in ClassSymbol)
+ case _ => super.resolveOverloadedFlag(flag)
+ }
private var tyconCache: Type = null
private var tyconRunId = NoRunId
@@ -2566,6 +2612,12 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
override protected def alwaysHasFlags: Long = 0L
override protected def neverHasFlags: Long = 0L
+ override def resolveOverloadedFlag(flag: Long) = flag match {
+ case INCONSTRUCTOR => "<inconstructor>" // CONTRAVARIANT / LABEL
+ case EXISTENTIAL => "<existential>" // MIXEDIN
+ case _ => super.resolveOverloadedFlag(flag)
+ }
+
final override def isClass = true
final override def isNonClassType = false
final override def isAbstractType = false
@@ -2799,7 +2851,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
unlock()
validTo = currentPeriod
}
- override def defaultFlagMask = AllFlags
+ override def flagMask = AllFlags
override def exists = false
override def isHigherOrderTypeParameter = false
override def companionClass = NoSymbol
diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala
index 1a40e0105c..c0d6f54b1a 100644
--- a/src/compiler/scala/reflect/internal/Trees.scala
+++ b/src/compiler/scala/reflect/internal/Trees.scala
@@ -42,7 +42,6 @@ trait Trees extends api.Trees { self: SymbolTable =>
}
/* Abstract types from HasFlags. */
- type FlagsType = Long
type AccessBoundaryType = Name
type AnnotationType = Tree
@@ -57,11 +56,7 @@ trait Trees extends api.Trees { self: SymbolTable =>
def hasAccessBoundary = privateWithin != tpnme.EMPTY
def hasAllFlags(mask: Long): Boolean = (flags & mask) == mask
def hasFlag(flag: Long) = (flag & flags) != 0L
- def hasFlagsToString(mask: Long): String = flagsToString(
- flags & mask,
- if (hasAccessBoundary) privateWithin.toString else ""
- )
- def defaultFlagString = hasFlagsToString(-1L)
+
def & (flag: Long): Modifiers = {
val flags1 = flags & flag
if (flags1 == flags) this
@@ -91,7 +86,7 @@ trait Trees extends api.Trees { self: SymbolTable =>
override def mapAnnotations(f: List[Tree] => List[Tree]): Modifiers =
Modifiers(flags, privateWithin, f(annotations)) setPositions positions
- override def toString = "Modifiers(%s, %s, %s)".format(defaultFlagString, annotations mkString ", ", positions)
+ override def toString = "Modifiers(%s, %s, %s)".format(flagString, annotations mkString ", ", positions)
}
def Modifiers(flags: Long, privateWithin: Name): Modifiers = Modifiers(flags, privateWithin, List())
diff --git a/src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala b/src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala
index 85f7b56920..6d8aa8d1db 100644
--- a/src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala
+++ b/src/compiler/scala/reflect/runtime/SynchronizedSymbols.scala
@@ -25,7 +25,7 @@ trait SynchronizedSymbols extends internal.Symbols { self: SymbolTable =>
override def rawname = synchronized { super.rawname }
override def rawflags = synchronized { super.rawflags }
- override def rawflags_=(x: FlagsType) = synchronized { super.rawflags_=(x) }
+ override def rawflags_=(x: Long) = synchronized { super.rawflags_=(x) }
override def name_=(x: Name) = synchronized { super.name_=(x) }
override def owner_=(owner: Symbol) = synchronized { super.owner_=(owner) }
diff --git a/src/compiler/scala/tools/nsc/ast/DocComments.scala b/src/compiler/scala/tools/nsc/ast/DocComments.scala
index d3f4688d4b..4c7083a51f 100755
--- a/src/compiler/scala/tools/nsc/ast/DocComments.scala
+++ b/src/compiler/scala/tools/nsc/ast/DocComments.scala
@@ -523,10 +523,9 @@ trait DocComments { self: Global =>
}
for (defn <- defined) yield {
- val useCase = defn.cloneSymbol
- useCase.owner = sym.owner
- useCase.flags = sym.flags
- useCase.setFlag(Flags.SYNTHETIC).setInfo(substAliases(defn.info).asSeenFrom(site.thisType, sym.owner))
+ defn.cloneSymbol(sym.owner, sym.flags | Flags.SYNTHETIC) modifyInfo (info =>
+ substAliases(info).asSeenFrom(site.thisType, sym.owner)
+ )
}
}
}
diff --git a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
index dde166d64b..34bad05e1f 100644
--- a/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/src/compiler/scala/tools/nsc/transform/AddInterfaces.scala
@@ -106,7 +106,10 @@ abstract class AddInterfaces extends InfoTransform { self: Erasure =>
}
if (currentRun.compiles(iface)) currentRun.symSource(impl) = iface.sourceFile
impl setPos iface.pos
- impl.flags = implClassFlags
+ if (impl.flags != implClassFlags) {
+ log("!!! Directly setting impl class flags from %s to %s".format(flagsToString(impl.flags), flagsToString(implClassFlags)))
+ impl.flags = implClassFlags
+ }
impl setInfo new LazyImplClassType(iface)
implClassMap(iface) = impl
debuglog(
diff --git a/src/compiler/scala/tools/nsc/transform/Mixin.scala b/src/compiler/scala/tools/nsc/transform/Mixin.scala
index ed410a76db..6d4dab57a3 100644
--- a/src/compiler/scala/tools/nsc/transform/Mixin.scala
+++ b/src/compiler/scala/tools/nsc/transform/Mixin.scala
@@ -389,11 +389,14 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
var sourceModule = clazz.owner.info.decls.lookup(sym.name.toTermName)
if (sourceModule != NoSymbol) {
sourceModule setPos sym.pos
- sourceModule.flags = MODULE | FINAL
+ if (sourceModule.flags != MODULE) {
+ log("!!! Directly setting sourceModule flags from %s to MODULE".format(flagsToString(sourceModule.flags)))
+ sourceModule.flags = MODULE
+ }
}
else {
sourceModule = (
- clazz.owner.newModuleSymbol(sym.name.toTermName, sym.pos, MODULE | FINAL)
+ clazz.owner.newModuleSymbol(sym.name.toTermName, sym.pos, MODULE)
setModuleClass sym.asInstanceOf[ClassSymbol]
)
clazz.owner.info.decls enter sourceModule
@@ -935,7 +938,7 @@ abstract class Mixin extends InfoTransform with ast.TreeDSL {
private def checkedGetter(lhs: Tree) = {
val sym = clazz.info decl lhs.symbol.getterName suchThat (_.isGetter)
if (needsInitAndHasOffset(sym)) {
- debuglog("adding checked getter for: " + sym + " " + lhs.symbol.defaultFlagString)
+ debuglog("adding checked getter for: " + sym + " " + lhs.symbol.flagString)
List(localTyper typed mkSetFlag(clazz, fieldOffset(sym), sym))
}
else Nil
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index b57f139074..04341fea25 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -304,7 +304,7 @@ trait MethodSynthesis {
}
}
private def logDerived(result: Tree): Tree = {
- debuglog("[+derived] " + ojoin(mods.defaultFlagString, basisSym.accurateKindString, basisSym.getterName.decode)
+ debuglog("[+derived] " + ojoin(mods.flagString, basisSym.accurateKindString, basisSym.getterName.decode)
+ " (" + derivedSym + ")\n " + result)
result
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 7ea78a81d5..ed17d6efa7 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1362,7 +1362,7 @@ trait Namers extends MethodSynthesis {
}
}
private val logDefinition = new LogTransitions[Symbol](
- sym => "[define] >> " + sym.defaultFlagString + " " + sym.fullLocationString,
+ sym => "[define] >> " + sym.flagString + " " + sym.fullLocationString,
sym => "[define] << " + sym
)
private def logAndValidate(sym: Symbol)(body: => Unit) {
diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check
index f198e61072..96e257d303 100644
--- a/test/files/run/compiler-asSeenFrom.check
+++ b/test/files/run/compiler-asSeenFrom.check
@@ -187,69 +187,69 @@ class J {
D[A1]#J[T4] Z.dZ.J[P] D[A1]#J[P]
}
class D { // after parser
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD: ll.C[List[T3]]
}
class D { // after uncurry
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD(): ll.C[List[T3]]
}
class D { // after erasure
- private val cD: ll.C
+ private[this] val cD: ll.C
val cD(): ll.C
}
object Z { // after parser
def kz[P <: ll.Z.dZ.J[ll.A2]]: ll.Z.dZ.J[P]
- private val jZ: ll.Z.dZ.J[ll.A2]
+ private[this] val jZ: ll.Z.dZ.J[ll.A2]
val jZ: ll.Z.dZ.J[ll.A2]
- private val dZ: ll.D[ll.A1]
+ private[this] val dZ: ll.D[ll.A1]
val dZ: ll.D[ll.A1]
}
object Z { // after uncurry
def kz[P <: ll.Z.dZ.J[ll.A2]](): ll.Z.dZ.J[P]
- private val jZ: ll.Z.dZ.J[ll.A2]
+ private[this] val jZ: ll.Z.dZ.J[ll.A2]
val jZ(): ll.Z.dZ.J[ll.A2]
- private val dZ: ll.D[ll.A1]
+ private[this] val dZ: ll.D[ll.A1]
val dZ(): ll.D[ll.A1]
}
object Z { // after erasure
def kz(): ll.D#J
- private val jZ: ll.D#J
+ private[this] val jZ: ll.D#J
val jZ(): ll.D#J
- private val dZ: ll.D
+ private[this] val dZ: ll.D
val dZ(): ll.D
}
object Z { // after flatten
def kz(): ll.D#D$J
- private val jZ: ll.D#D$J
+ private[this] val jZ: ll.D#D$J
val jZ(): ll.D#D$J
- private val dZ: ll.D
+ private[this] val dZ: ll.D
val dZ(): ll.D
}
value dZ { // after parser
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD: ll.C[List[T3]]
}
value dZ { // after parser
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD: ll.C[List[T3]]
}
value dZ { // after uncurry
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD(): ll.C[List[T3]]
}
value dZ { // after erasure
- private val cD: ll.C
+ private[this] val cD: ll.C
val cD(): ll.C
}
@@ -307,17 +307,17 @@ method kz { // after parser
}
value $outer { // after parser
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD: ll.C[List[T3]]
}
value $outer { // after uncurry
- private val cD: ll.C[List[T3]]
+ private[this] val cD: ll.C[List[T3]]
val cD(): ll.C[List[T3]]
}
value $outer { // after erasure
- private val cD: ll.C
+ private[this] val cD: ll.C
val cD(): ll.C
}