summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/concurrent/impl/ExecutionContextImpl.scala2
-rw-r--r--src/library/scala/concurrent/impl/Future.scala2
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala2
-rw-r--r--src/library/scala/parallel/Future.scala3
-rw-r--r--src/library/scala/reflect/api/Positions.scala18
-rw-r--r--src/library/scala/reflect/api/Trees.scala19
6 files changed, 34 insertions, 12 deletions
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
index dd1de2025e..8ac745fd25 100644
--- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
+++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -19,7 +19,7 @@ import scala.collection.mutable.Stack
-class ExecutionContextImpl(val executorService: AnyRef) extends ExecutionContext {
+private[scala] class ExecutionContextImpl(val executorService: AnyRef) extends ExecutionContext {
import ExecutionContextImpl._
def execute(runnable: Runnable): Unit = executorService match {
diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala
index 9466761d4d..b4385ea34a 100644
--- a/src/library/scala/concurrent/impl/Future.scala
+++ b/src/library/scala/concurrent/impl/Future.scala
@@ -12,7 +12,7 @@ import scala.concurrent.{Awaitable, ExecutionContext}
import scala.util.{ Try, Success, Failure }
//import scala.util.continuations._
-trait Future[+T] extends scala.concurrent.Future[T] with Awaitable[T] {
+private[concurrent] trait Future[+T] extends scala.concurrent.Future[T] with Awaitable[T] {
implicit def executor: ExecutionContextImpl
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 3d40ae6930..4a983b5001 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -22,7 +22,7 @@ import scala.annotation.tailrec
-trait Promise[T] extends scala.concurrent.Promise[T] with Future[T] {
+private[concurrent] trait Promise[T] extends scala.concurrent.Promise[T] with Future[T] {
def future = this
diff --git a/src/library/scala/parallel/Future.scala b/src/library/scala/parallel/Future.scala
index af06852b32..f61d376093 100644
--- a/src/library/scala/parallel/Future.scala
+++ b/src/library/scala/parallel/Future.scala
@@ -8,11 +8,14 @@
package scala.parallel
+
+
/** A future is a function without parameters that will block the caller if
* the parallel computation associated with the function is not completed.
*
* @since 2.9
*/
+@deprecated("Use `scala.concurrent.Future` instead.", "2.10.0")
trait Future[@specialized +R] extends (() => R) {
/** Returns a result once the parallel computation completes. If the
* computation produced an exception, an exception is forwarded.
diff --git a/src/library/scala/reflect/api/Positions.scala b/src/library/scala/reflect/api/Positions.scala
index 181e7c1525..4c8c33bec8 100644
--- a/src/library/scala/reflect/api/Positions.scala
+++ b/src/library/scala/reflect/api/Positions.scala
@@ -1,9 +1,21 @@
package scala.reflect
package api
-trait Positions {
+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
+ type Position // <: TreeAnnotation, but not practical to enforce this (would require moving Position, SourceFile, Reporter,... into the universe)
val NoPosition: Position
-
} \ No newline at end of file
diff --git a/src/library/scala/reflect/api/Trees.scala b/src/library/scala/reflect/api/Trees.scala
index 466c380cef..4ee13adf52 100644
--- a/src/library/scala/reflect/api/Trees.scala
+++ b/src/library/scala/reflect/api/Trees.scala
@@ -74,17 +74,24 @@ trait Trees { self: Universe =>
val id = nodeCount
nodeCount += 1
- private[this] var rawpos: Position = NoPosition
-
/** Prefix under which to print this tree type. Defaults to product
* prefix (e.g. DefTree) but because that is used in reification
* it cannot be altered without breaking reflection.
*/
def printingPrefix = productPrefix
- def pos = rawpos
- def pos_=(pos: Position) = rawpos = pos
- def setPos(pos: Position): this.type = { rawpos = pos; this }
+ def pos: Position = annotationToPosition(rawannot)
+ def pos_=(pos: Position): Unit = annotation = pos
+ def setPos(newpos: Position): this.type = { pos = newpos; this }
+
+ private[this] var rawannot: TreeAnnotation = NoTreeAnnotation
+ def annotation: TreeAnnotation = rawannot
+ def annotation_=(annot: TreeAnnotation): Unit = {
+ _checkSetAnnotation(this, annot)
+ rawannot = annot
+ }
+
+ def setAnnotation(annot: TreeAnnotation): this.type = { annotation = annot; this }
private[this] var rawtpe: Type = _
@@ -223,7 +230,7 @@ trait Trees { self: Universe =>
duplicateTree(this).asInstanceOf[this.type]
private[scala] def copyAttrs(tree: Tree): this.type = {
- pos = tree.pos
+ annotation = tree.annotation
tpe = tree.tpe
if (hasSymbol) symbol = tree.symbol
this