summaryrefslogtreecommitdiff
path: root/src/library/scala/reflect/api/Attachments.scala
blob: dfd362ebe0c2cb23d67616ada322a9203f614540 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package scala.reflect
package api

/** Attachment is a generalisation of Position.
 *  Typically it stores a Position of a tree, but this can be extended to encompass arbitrary payloads.
 *
 *  Attachments have to carry positions, because we don't want to introduce even a single additional field in Tree
 *  imposing an unnecessary memory tax because of something that will not be used in most cases.
 */
trait Attachment {
  /** Gets the underlying position */
  def pos: Position

  /** Creates a copy of this attachment with its position updated */
  def withPos(pos: Position): Attachment
}