aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-07-01 15:59:33 +0200
committerMartin Odersky <odersky@gmail.com>2015-07-06 17:46:45 +0200
commit84ad34ad7a50a7f9d39d6958a7b8840e16c37a3c (patch)
tree309525b19d9f063a384d4e2561f0b29a34986c43 /src/dotty/tools/dotc/core
parent64f65182f6e4f80b03d45923e02441dafe0755b4 (diff)
downloaddotty-84ad34ad7a50a7f9d39d6958a7b8840e16c37a3c.tar.gz
dotty-84ad34ad7a50a7f9d39d6958a7b8840e16c37a3c.tar.bz2
dotty-84ad34ad7a50a7f9d39d6958a7b8840e16c37a3c.zip
Add @sharable annotation
Add @sharable annotation for classes and vals that are presumed to be safely sharable between threads. Also: Document CtxLazy.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r--src/dotty/tools/dotc/core/Contexts.scala5
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala9
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala5
-rw-r--r--src/dotty/tools/dotc/core/Types.scala16
4 files changed, 20 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala
index c9deaab10..206ef9d8b 100644
--- a/src/dotty/tools/dotc/core/Contexts.scala
+++ b/src/dotty/tools/dotc/core/Contexts.scala
@@ -28,6 +28,7 @@ import printing._
import config.{Settings, ScalaSettings, Platform, JavaPlatform}
import language.implicitConversions
import DenotTransformers.DenotTransformer
+
object Contexts {
/** A context is passed basically everywhere in dotc.
@@ -473,7 +474,7 @@ object Contexts {
gadt = new GADTMap(SimpleMap.Empty)
}
- object NoContext extends Context {
+ @sharable object NoContext extends Context {
lazy val base = unsupported("base")
override val implicits: ContextualImplicits = new ContextualImplicits(Nil, null)(this)
}
@@ -620,7 +621,7 @@ object Contexts {
/** implicit conversion that injects all ContextBase members into a context */
implicit def toBase(ctx: Context): ContextBase = ctx.base
- val theBase = new ContextBase // !!! DEBUG, so that we can use a minimal context for reporting even in code that normally cannot access a context
+ // @sharable val theBase = new ContextBase // !!! DEBUG, so that we can use a minimal context for reporting even in code that normally cannot access a context
}
/** Info that changes on each compiler run */
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 164b0b8f3..53973b587 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -1,4 +1,5 @@
-package dotty.tools.dotc
+package dotty.tools
+package dotc
package core
import Periods._, Contexts._, Symbols._, Denotations._, Names._, NameOps._, Annotations._
@@ -1713,8 +1714,8 @@ object SymDenotations {
validFor = Period.allInRun(NoRunId) // will be brought forward automatically
}
- val NoDenotation = new NoDenotation
- val NotDefinedHereDenotation = new NoDenotation
+ @sharable val NoDenotation = new NoDenotation
+ @sharable val NotDefinedHereDenotation = new NoDenotation
// ---- Completion --------------------------------------------------------
@@ -1757,7 +1758,7 @@ object SymDenotations {
val NoSymbolFn = (ctx: Context) => NoSymbol
/** A missing completer */
- class NoCompleter extends LazyType {
+ @sharable class NoCompleter extends LazyType {
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = unsupported("complete")
}
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index 2b2ef83a2..b61d39749 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -1,4 +1,5 @@
-package dotty.tools.dotc
+package dotty.tools
+package dotc
package core
import Contexts._, Types._, Symbols._, Names._, Flags._, Scopes._
@@ -572,5 +573,5 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
object TypeOps {
val emptyDNF = (Nil, Set[Name]()) :: Nil
- var track = false // !!!DEBUG
+ @sharable var track = false // !!!DEBUG
}
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index d6bb9c3c5..85e2634d4 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1,4 +1,5 @@
-package dotty.tools.dotc
+package dotty.tools
+package dotc
package core
import util.common._
@@ -35,7 +36,7 @@ import language.implicitConversions
object Types {
- private var nextId = 0
+ @sharable private var nextId = 0
/** The class of types.
* The principal subclasses and sub-objects are as follows:
@@ -73,6 +74,7 @@ object Types {
// ----- Tests -----------------------------------------------------
+ // debug only: a unique identifier for a type
val uniqId = {
nextId = nextId + 1
// if (nextId == 19555)
@@ -2752,13 +2754,13 @@ object Types {
case class ImportType(expr: Tree) extends UncachedGroundType
/** Sentinel for "missing type" */
- case object NoType extends CachedGroundType {
+ @sharable case object NoType extends CachedGroundType {
override def exists = false
override def computeHash = hashSeed
}
/** Missing prefix */
- case object NoPrefix extends CachedGroundType {
+ @sharable case object NoPrefix extends CachedGroundType {
override def computeHash = hashSeed
}
@@ -2775,7 +2777,7 @@ object Types {
final class CachedWildcardType(optBounds: Type) extends WildcardType(optBounds)
- object WildcardType extends WildcardType(NoType) {
+ @sharable object WildcardType extends WildcardType(NoType) {
def apply(bounds: TypeBounds)(implicit ctx: Context) = unique(new CachedWildcardType(bounds))
}
@@ -2983,7 +2985,7 @@ object Types {
}
}
- object IdentityTypeMap extends TypeMap()(NoContext) {
+ @sharable object IdentityTypeMap extends TypeMap()(NoContext) {
override def stopAtStatic = true
def apply(tp: Type) = tp
}
@@ -3208,7 +3210,7 @@ object Types {
// ----- Debug ---------------------------------------------------------
- var debugTrace = false
+ @sharable var debugTrace = false
val watchList = List[String](
) map (_.toTypeName)