summaryrefslogblamecommitdiff
path: root/src/reflect/scala/reflect/internal/StdAttachments.scala
blob: 60b3a6f4363e67b8235313558e5f20354ba8243e (plain) (tree)
1
2
3
4
5
6


                     


                      














                                                                                             
                                            



                                                                                       
 
package scala.reflect
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)
}