diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2012-07-02 17:25:18 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2012-07-05 14:36:44 +0200 |
commit | 70503355299263f95a3447701bb483375bf46665 (patch) | |
tree | 70439d6bca065cc9b28c5f681e86bef3e7a6f9ad /src/reflect/scala/reflect/internal/StdAttachments.scala | |
parent | 4b6ae392a7aaf147de3991998d52be5e7b7e665e (diff) | |
download | scala-70503355299263f95a3447701bb483375bf46665.tar.gz scala-70503355299263f95a3447701bb483375bf46665.tar.bz2 scala-70503355299263f95a3447701bb483375bf46665.zip |
Allow attachments for symbols, just like for trees.
Removes the two global hash maps in Namers, and the one in NamesDefaults. Also fixes SI-5975.
Diffstat (limited to 'src/reflect/scala/reflect/internal/StdAttachments.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/StdAttachments.scala | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/StdAttachments.scala b/src/reflect/scala/reflect/internal/StdAttachments.scala index 4ea9b27da9..60b3a6f436 100644 --- a/src/reflect/scala/reflect/internal/StdAttachments.scala +++ b/src/reflect/scala/reflect/internal/StdAttachments.scala @@ -4,9 +4,24 @@ package internal trait StdAttachments { self: SymbolTable => + /** + * Common code between reflect-internal Symbol and Tree related to Attachments. + */ + trait Attachable { + protected var rawatt: base.Attachments { type Pos = Position } = NoPosition + def attachments = rawatt + def addAttachment(attachment: Any): this.type = { rawatt = rawatt.add(attachment); this } + def removeAttachment[T: ClassTag]: this.type = { rawatt = rawatt.remove[T]; this } + + // cannot be final due to SynchronizedSymbols + def pos: Position = rawatt.pos + def pos_=(pos: Position): Unit = rawatt = (rawatt withPos pos) + def setPos(newpos: Position): this.type = { pos = newpos; this } + } + case object BackquotedIdentifierAttachment case class CompoundTypeTreeOriginalAttachment(parents: List[Tree], stats: List[Tree]) case class MacroExpansionAttachment(original: Tree) -}
\ No newline at end of file +} |