Class scala.reflect.macros.Attachments
abstract class Attachments extends AnyRef
Instance Constructors
new Attachments()
Type Members
abstract type Pos >: Null
Abstract Value Members
abstract def pos: Pos
abstract def withPos(newPos: Pos): Attachments { type Pos = Attachments.this.Pos }
Concrete Value Members
final def !=(arg0: Any): Boolean
final def ##(): Int
def +(other: String): String
final def ==(arg0: Any): Boolean
def all: Set[Any]
final def asInstanceOf[T0]: T0
def clone(): AnyRef
def contains[T](implicit arg0: ClassTag[T]): Boolean
def ensuring(cond: (Attachments) => Boolean, msg: => Any): Attachments
def ensuring(cond: Boolean, msg: => Any): Attachments
def ensuring(cond: Boolean): Attachments
final def eq(arg0: AnyRef): Boolean
def equals(arg0: AnyRef): Boolean
def finalize(): Unit
def get[T](implicit arg0: ClassTag[T]): Option[T]
final def getClass(): Class[_ <: AnyRef]
def hashCode(): Int
def isEmpty: Boolean
final def isInstanceOf[T0]: Boolean
final def ne(arg0: AnyRef): Boolean
final def notify(): Unit
final def notifyAll(): Unit
def remove[T](implicit arg0: ClassTag[T]): Attachments { type Pos = Attachments.this.Pos }
final def synchronized[T0](arg0: => T0): T0
def toString(): String
def update[T](attachment: T)(implicit arg0: ClassTag[T]): Attachments { type Pos = Attachments.this.Pos }
final def wait(): Unit
final def wait(arg0: Long, arg1: Int): Unit
final def wait(arg0: Long): Unit
EXPERIMENTAL
Attachments provide a way to associate custom metadata with symbols and trees.
Along with
symbol
andtpe
, which represent core metadata of trees, each tree carries theattachments
field that can store other metadata: compiler-defined (e.g. positions) or user-defined. Same story is true for symbols, which also have extensible metadata by the virtue of the sameattachments
field.Typically attachments just store a scala.reflect.api.Position, but they can be extended to encompass arbitrary payloads. Payloads are stored in type-indexed slots, which can be read with
get[T]
and written withupdate[T]
andremove[T]
.This API doesn't have much use in the runtime reflection API (the scala.reflect.api package), but it might be of help for macro writers, providing a way to coordinate multiple macros operating on the same code. Therefore the
attachments
field is only declared in trees and symbols belonging to scala.reflect.macros.Universe.