summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/internal/Flags.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-09-27 00:32:40 -0700
committerPaul Phillips <paulp@improving.org>2013-09-27 00:34:13 -0700
commit693ecffbaf5be036e05300a1ee3a8444c0ac0fe3 (patch)
tree1032802cd3e29e7bb9c8cd2abad8dcb0a0b3ed8f /src/reflect/scala/reflect/internal/Flags.scala
parent0aaf59149871f817a67c1fefcc3b0457fcb5e4fc (diff)
downloadscala-693ecffbaf5be036e05300a1ee3a8444c0ac0fe3.tar.gz
scala-693ecffbaf5be036e05300a1ee3a8444c0ac0fe3.tar.bz2
scala-693ecffbaf5be036e05300a1ee3a8444c0ac0fe3.zip
Fix up DEFAULTPARAM semantics.
I foolishly believed the deprecation message on "hasDefaultFlag" which suggested I use "hasDefault" instead. After lots of head scratching, I hardened the semantics so it's like this: - A method parameter with a default value is PARAM | DEFAULTPARAM - A default getter for such a parameter is METHOD | DEFAULTPARAM - And "hasDefault" is has(DEFAULTPARAM) && has(PARAM | METHOD) Why all the bonus logic, why not just hasFlag(DEFAULTPARAM)? For some reason we have a handful of overloaded flags spanning uses which someone apparently thinks can never intersect but I have not been so lucky overall. So since DEFAULTPARAM is overloaded with TRAIT, unless we think it's fine that default getters and method parameters with defaults will pose as traits all the time, there has to be an anchor bit alongside it.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Flags.scala')
-rw-r--r--src/reflect/scala/reflect/internal/Flags.scala13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/Flags.scala b/src/reflect/scala/reflect/internal/Flags.scala
index c286ea53c6..dcdf6728ce 100644
--- a/src/reflect/scala/reflect/internal/Flags.scala
+++ b/src/reflect/scala/reflect/internal/Flags.scala
@@ -279,11 +279,13 @@ class Flags extends ModifierFlags {
final val GetterFlags = ~(PRESUPER | MUTABLE)
final val SetterFlags = ~(PRESUPER | MUTABLE | STABLE | CASEACCESSOR | IMPLICIT)
- /** When a symbol for a default getter is created, it inherits these
- * flags from the method with the default. Other flags applied at creation
- * time are SYNTHETIC, DEFAULTPARAM, and possibly OVERRIDE, and maybe PRESUPER.
+ /** Since DEFAULTPARAM is overloaded with TRAIT, we need some additional
+ * means of determining what that bit means. Usually DEFAULTPARAM is coupled
+ * with PARAM, which suffices. Default getters get METHOD instead.
+ * This constant is the mask of flags which can survive from the parameter modifiers.
+ * See paramFlagsToDefaultGetter for the full logic.
*/
- final val DefaultGetterFlags = PRIVATE | PROTECTED | FINAL
+ final val DefaultGetterFlags = PRIVATE | PROTECTED | FINAL | PARAMACCESSOR
/** When a symbol for a method parameter is created, only these flags survive
* from Modifiers. Others which may be applied at creation time are:
@@ -321,6 +323,9 @@ class Flags extends ModifierFlags {
*/
final val TopLevelPickledFlags = PickledFlags & ~(MODULE | METHOD | PACKAGE | PARAM | EXISTENTIAL)
+ def paramFlagsToDefaultGetter(paramFlags: Long): Long =
+ (paramFlags & DefaultGetterFlags) | SYNTHETIC | METHOD | DEFAULTPARAM
+
def getterFlags(fieldFlags: Long): Long = ACCESSOR + (
if ((fieldFlags & MUTABLE) != 0) fieldFlags & ~MUTABLE & ~PRESUPER
else fieldFlags & ~PRESUPER | STABLE