diff options
author | Paul Phillips <paulp@improving.org> | 2012-08-15 18:21:28 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-08-15 18:21:28 -0700 |
commit | 69c7e24e547b0b8ad0ac92869fbb920d7a008eac (patch) | |
tree | 60bf10a6c8a888c4c30ebd48f5b61c8bbfff3b16 /src/reflect | |
parent | d66c7a4fea537d142e42da91bfe87f4aaecc1821 (diff) | |
parent | 37a290b02ef09c7e563239d878088aa30405eecb (diff) | |
download | scala-69c7e24e547b0b8ad0ac92869fbb920d7a008eac.tar.gz scala-69c7e24e547b0b8ad0ac92869fbb920d7a008eac.tar.bz2 scala-69c7e24e547b0b8ad0ac92869fbb920d7a008eac.zip |
Merge pull request #1114 from scalamacros/topic/is-artifact
Introduces the `isArtifact` test for symbols
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/api/Symbols.scala | 5 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Flags.scala | 22 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/HasFlags.scala | 8 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 5 |
4 files changed, 23 insertions, 17 deletions
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala index fda76c7b95..3415b0fa10 100644 --- a/src/reflect/scala/reflect/api/Symbols.scala +++ b/src/reflect/scala/reflect/api/Symbols.scala @@ -67,6 +67,11 @@ trait Symbols extends base.Symbols { self: Universe => */ def isSynthetic: Boolean + /** Does this symbol represent an implementation artifact that isn't meant for public use? + * Examples of such artifacts are erasure bridges and $outer fields. + */ + def isImplementationArtifact: Boolean + /** Does this symbol represent a local declaration or definition? * * If yes, either `isPrivate` or `isProtected` are guaranteed to be true. diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala index f3f3bf5ce8..0eb839479a 100644 --- a/src/reflect/scala/reflect/internal/Flags.scala +++ b/src/reflect/scala/reflect/internal/Flags.scala @@ -135,7 +135,7 @@ class Flags extends ModifierFlags { final val CAPTURED = 1 << 16 // variable is accessed from nested function. Set by LambdaLift. final val LABEL = 1 << 17 // method symbol is a label. Set by TailCall final val INCONSTRUCTOR = 1 << 17 // class symbol is defined in this/superclass constructor. - final val SYNTHETIC = 1 << 21 // symbol is compiler-generated (compare with HIDDEN) + final val SYNTHETIC = 1 << 21 // symbol is compiler-generated (compare with ARTIFACT) final val STABLE = 1 << 22 // functions that are assumed to be stable // (typically, access methods for valdefs) // or classes that do not contain abstract types. @@ -165,7 +165,7 @@ class Flags extends ModifierFlags { // A Java method's type is ``cooked'' by transforming raw types to existentials final val SYNCHRONIZED = 1L << 45 // symbol is a method which should be marked ACC_SYNCHRONIZED - final val HIDDEN = 1L << 46 // symbol should be ignored when typechecking; will be marked ACC_SYNTHETIC in bytecode + final val ARTIFACT = 1L << 46 // symbol should be ignored when typechecking; will be marked ACC_SYNTHETIC in bytecode // ------- shift definitions ------------------------------------------------------- @@ -218,7 +218,7 @@ class Flags extends ModifierFlags { /** To be a little clearer to people who aren't habitual bit twiddlers. */ final val AllFlags = -1L - + /** These flags can be set when class or module symbol is first created. * They are the only flags to survive a call to resetFlags(). */ @@ -288,11 +288,11 @@ class Flags extends ModifierFlags { /** These flags are not pickled */ final val FlagsNotPickled = IS_ERROR | OVERLOADED | LIFTED | TRANS_FLAG | LOCKED | TRIEDCOOKING - + // A precaution against future additions to FlagsNotPickled turning out // to be overloaded flags thus not-pickling more than intended. assert((OverloadedFlagsMask & FlagsNotPickled) == 0, flagsToString(OverloadedFlagsMask & FlagsNotPickled)) - + /** These flags are pickled */ final val PickledFlags = InitialFlags & ~FlagsNotPickled @@ -339,13 +339,13 @@ class Flags extends ModifierFlags { (SEALED, SEALED_PKL), (ABSTRACT, ABSTRACT_PKL) ) - + private val mappedRawFlags = rawPickledCorrespondence map (_._1) private val mappedPickledFlags = rawPickledCorrespondence map (_._2) - + private class MapFlags(from: Array[Long], to: Array[Long]) extends (Long => Long) { val fromSet = (0L /: from) (_ | _) - + def apply(flags: Long): Long = { var result = flags & ~fromSet var tobeMapped = flags & fromSet @@ -360,7 +360,7 @@ class Flags extends ModifierFlags { result } } - + val rawToPickledFlags: Long => Long = new MapFlags(mappedRawFlags, mappedPickledFlags) val pickledToRawFlags: Long => Long = new MapFlags(mappedPickledFlags, mappedRawFlags) @@ -434,7 +434,7 @@ class Flags extends ModifierFlags { case 0x8000000000000000L => "" // (1L << 63) case _ => "" } - + private def accessString(flags: Long, privateWithin: String)= ( if (privateWithin == "") { if ((flags & PrivateLocal) == PrivateLocal) "private[this]" @@ -446,7 +446,7 @@ class Flags extends ModifierFlags { else if ((flags & PROTECTED) != 0) "protected[" + privateWithin + "]" else "private[" + privateWithin + "]" ) - + @deprecated("Use flagString on the flag-carrying member", "2.10.0") def flagsToString(flags: Long, privateWithin: String): String = { val access = accessString(flags, privateWithin) diff --git a/src/reflect/scala/reflect/internal/HasFlags.scala b/src/reflect/scala/reflect/internal/HasFlags.scala index 7ead9d6a1b..62c8ed702b 100644 --- a/src/reflect/scala/reflect/internal/HasFlags.scala +++ b/src/reflect/scala/reflect/internal/HasFlags.scala @@ -66,7 +66,7 @@ trait HasFlags { */ 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 @@ -92,7 +92,7 @@ trait HasFlags { def isCaseAccessor = hasFlag(CASEACCESSOR) def isDeferred = hasFlag(DEFERRED) def isFinal = hasFlag(FINAL) - def isHidden = hasFlag(HIDDEN) + def isArtifact = hasFlag(ARTIFACT) def isImplicit = hasFlag(IMPLICIT) def isInterface = hasFlag(INTERFACE) def isJavaDefined = hasFlag(JAVA) @@ -136,7 +136,7 @@ trait HasFlags { def accessString: String = { val pw = if (hasAccessBoundary) privateWithin.toString else "" - + if (pw == "") { if (hasAllFlags(PrivateLocal)) "private[this]" else if (hasAllFlags(ProtectedLocal)) "protected[this]" @@ -150,7 +150,7 @@ trait HasFlags { protected def calculateFlagString(basis: Long): String = { val access = accessString val nonAccess = flagBitsToString(basis & ~AccessFlags) - + if (access == "") nonAccess else if (nonAccess == "") access else nonAccess + " " + access diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index ac8b254f83..6c9cfd1972 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -66,6 +66,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => def isExistential: Boolean = this.isExistentiallyBound def isParamWithDefault: Boolean = this.hasDefault def isByNameParam: Boolean = this.isValueParameter && (this hasFlag BYNAMEPARAM) + def isImplementationArtifact: Boolean = (this hasFlag BRIDGE) || (this hasFlag VBRIDGE) || (this hasFlag ARTIFACT) def newNestedSymbol(name: Name, pos: Position, newFlags: Long, isClass: Boolean): Symbol = name match { case n: TermName => newTermSymbol(n, pos, newFlags) @@ -698,13 +699,13 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** Is this symbol an accessor method for outer? */ final def isOuterAccessor = { - hasFlag(STABLE | HIDDEN) && + hasFlag(STABLE | ARTIFACT) && originalName == nme.OUTER } /** Is this symbol an accessor method for outer? */ final def isOuterField = { - hasFlag(HIDDEN) && + hasFlag(ARTIFACT) && originalName == nme.OUTER_LOCAL } |