summaryrefslogtreecommitdiff
path: root/src/library/scala/reflect/api/Positions.scala
blob: 4c8c33bec8d135fd146adfc7565a3492442c7517 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package scala.reflect
package api

trait Positions { self: Universe =>
  /** TreeAnnotation is a generalisation of Position.
   *
   * TreeAnnotation cannot be an upperbound of Position since the corresponding classes
   * must live outside of the universe for backwards compatibility (see scala.tools.nsc.util.Position).
   * Thus, represent subtyping as coercions.
   *
   * Typically, positionToAnnotation is the identity, and annotationToPosition returns annot.pos
   */
  type TreeAnnotation // <: { def pos: Position }
  val NoTreeAnnotation: TreeAnnotation
  implicit def positionToAnnotation(pos: Position): TreeAnnotation  // = pos
  def annotationToPosition(annot: TreeAnnotation): Position         // = annot.pos
  def _checkSetAnnotation(tree: Tree, annot: TreeAnnotation): Unit = () // check that annot may overwrite tree.annot

  type Position // <: TreeAnnotation, but not practical to enforce this (would require moving Position, SourceFile, Reporter,... into the universe)
  val NoPosition: Position
}