diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-02-15 01:48:34 +0100 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-15 09:32:28 +0100 |
commit | c9ca7370575ef2245b03ead50ec86fad99c3cce9 (patch) | |
tree | cc062e1441d23e85d0864d2a7e098bda72e968ab /src/reflect/scala | |
parent | 25e7274ef7f0ffaf511460c3a130c8064b5d44e2 (diff) | |
download | scala-c9ca7370575ef2245b03ead50ec86fad99c3cce9.tar.gz scala-c9ca7370575ef2245b03ead50ec86fad99c3cce9.tar.bz2 scala-c9ca7370575ef2245b03ead50ec86fad99c3cce9.zip |
SI-6785 exposes Symbol.flags, setFlag and resetFlag
My first feeling was not to expose Symbol.flags, because that would
inevitably lead to exposing more methods on FlagSet. However we do need
flag manipulation in async, which is representative of advanced macros,
so I'm caving in.
Diffstat (limited to 'src/reflect/scala')
-rw-r--r-- | src/reflect/scala/reflect/api/Internals.scala | 7 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Internals.scala | 3 | ||||
-rw-r--r-- | src/reflect/scala/reflect/macros/Universe.scala | 12 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala index 913177040c..4614a79c26 100644 --- a/src/reflect/scala/reflect/api/Internals.scala +++ b/src/reflect/scala/reflect/api/Internals.scala @@ -251,6 +251,10 @@ trait Internals { self: Universe => */ def fullyInitialize(scope: Scope): scope.type + /** Returns internal flags associated with the symbol. + */ + def flags(symbol: Symbol): FlagSet + /** A creator for `ThisType` types. */ def thisType(sym: Symbol): Type @@ -436,6 +440,9 @@ trait Internals { self: Universe => /** @see [[internal.fullyInitialize]] */ def fullyInitialize: T = internal.fullyInitialize(symbol) + + /** @see [[internal.flags]] */ + def flags: FlagSet = internal.flags(symbol) } /** Extension methods for types */ diff --git a/src/reflect/scala/reflect/internal/Internals.scala b/src/reflect/scala/reflect/internal/Internals.scala index 994b907042..a283dd819a 100644 --- a/src/reflect/scala/reflect/internal/Internals.scala +++ b/src/reflect/scala/reflect/internal/Internals.scala @@ -93,6 +93,7 @@ trait Internals extends api.Internals { def fullyInitialize(symbol: Symbol): symbol.type = definitions.fullyInitializeSymbol(symbol).asInstanceOf[symbol.type] def fullyInitialize(tp: Type): tp.type = definitions.fullyInitializeType(tp).asInstanceOf[tp.type] def fullyInitialize(scope: Scope): scope.type = definitions.fullyInitializeScope(scope).asInstanceOf[scope.type] + def flags(symbol: Symbol): FlagSet = symbol.flags def attachments(symbol: Symbol): Attachments { type Pos = Position } = symbol.attachments def updateAttachment[T: ClassTag](symbol: Symbol, attachment: T): symbol.type = symbol.updateAttachment(attachment) def removeAttachment[T: ClassTag](symbol: Symbol): symbol.type = symbol.removeAttachment[T] @@ -101,6 +102,8 @@ trait Internals extends api.Internals { def setAnnotations(symbol: Symbol, annots: Annotation*): symbol.type = symbol.setAnnotations(annots: _*) def setName(symbol: Symbol, name: Name): symbol.type = symbol.setName(name) def setPrivateWithin(symbol: Symbol, sym: Symbol): symbol.type = symbol.setPrivateWithin(sym) + def setFlag(symbol: Symbol, flags: FlagSet): symbol.type = symbol.setFlag(flags) + def resetFlag(symbol: Symbol, flags: FlagSet): symbol.type = symbol.resetFlag(flags) def thisType(sym: Symbol): Type = self.ThisType(sym) def singleType(pre: Type, sym: Symbol): Type = self.SingleType(pre, sym) diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala index 08436df5a7..039dcc7331 100644 --- a/src/reflect/scala/reflect/macros/Universe.scala +++ b/src/reflect/scala/reflect/macros/Universe.scala @@ -74,6 +74,12 @@ abstract class Universe extends scala.reflect.api.Universe { /** Sets the `privateWithin` of the symbol. */ def setPrivateWithin(symbol: Symbol, sym: Symbol): symbol.type + /** Enables `flags` on the symbol. */ + def setFlag(symbol: Symbol, flags: FlagSet): symbol.type + + /** Disables `flags` on the symbol. */ + def resetFlag(symbol: Symbol, flags: FlagSet): symbol.type + /** The attachment of the tree. */ def attachments(tree: Tree): Attachments { type Pos = Position } @@ -204,6 +210,12 @@ abstract class Universe extends scala.reflect.api.Universe { /** @see [[internal.setPrivateWithin]] */ def setPrivateWithin(sym: Symbol): T = internal.setPrivateWithin(symbol, sym) + + /** @see [[internal.setFlag]] */ + def setFlag(flags: FlagSet): T = internal.setFlag(symbol, flags) + + /** @see [[internal.setFlag]] */ + def resetFlag(flags: FlagSet): T = internal.resetFlag(symbol, flags) } } } |