summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2011-06-29 10:27:23 +0000
committerIulian Dragos <jaguarul@gmail.com>2012-11-06 09:33:33 +0100
commit03aa7fc3904033f8d2f6f14a87574a03553b7c72 (patch)
tree299f1f6ee47bfc401da29a0bb8bb3c3caf5bb743 /src/reflect
parent999918311b7bf764916431485cb11043f1c220ed (diff)
downloadscala-03aa7fc3904033f8d2f6f14a87574a03553b7c72.tar.gz
scala-03aa7fc3904033f8d2f6f14a87574a03553b7c72.tar.bz2
scala-03aa7fc3904033f8d2f6f14a87574a03553b7c72.zip
SI-6616 Check that unsafe operations are only called on the presentation compiler thread.
The method that checks the actual constraint is @elidable, expecting it to be used for nightly builds but stripped-off in release builds. This way we don't lose any performance, but 'fail-fast' in IDE nightlies. This assumes that release builds will have at least `-Xelide-below ASSERTION`, but this pull request does not do that.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/SymbolTable.scala6
-rw-r--r--src/reflect/scala/reflect/internal/Symbols.scala2
-rw-r--r--src/reflect/scala/reflect/internal/Types.scala1
3 files changed, 9 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala
index 2424e75949..881a5ee5d6 100644
--- a/src/reflect/scala/reflect/internal/SymbolTable.scala
+++ b/src/reflect/scala/reflect/internal/SymbolTable.scala
@@ -6,6 +6,7 @@
package scala.reflect
package internal
+import scala.annotation.elidable
import scala.collection.{ mutable, immutable }
import util._
@@ -107,6 +108,11 @@ abstract class SymbolTable extends macros.Universe
val global: SymbolTable.this.type = SymbolTable.this
} with util.TraceSymbolActivity
+ /** Check that the executing thread is the compiler thread. No-op here,
+ * overridden in interactive.Global. */
+ @elidable(elidable.WARNING)
+ def assertCorrectThread() {}
+
/** Are we compiling for Java SE? */
// def forJVM: Boolean
diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala
index a6f156f947..449102dc00 100644
--- a/src/reflect/scala/reflect/internal/Symbols.scala
+++ b/src/reflect/scala/reflect/internal/Symbols.scala
@@ -1213,6 +1213,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
}
val current = phase
try {
+ assertCorrectThread()
phase = phaseOf(infos.validFrom)
tp.complete(this)
} finally {
@@ -1283,6 +1284,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
infos = infos.prev
if (validTo < curPeriod) {
+ assertCorrectThread()
// adapt any infos that come from previous runs
val current = phase
try {
diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala
index 403bf7d492..cdfff12855 100644
--- a/src/reflect/scala/reflect/internal/Types.scala
+++ b/src/reflect/scala/reflect/internal/Types.scala
@@ -146,6 +146,7 @@ trait Types extends api.Types { self: SymbolTable =>
/** Undo all changes to constraints to type variables upto `limit`. */
//OPT this method is public so we can do `manual inlining`
def undoTo(limit: UndoPairs) {
+ assertCorrectThread()
while ((log ne limit) && log.nonEmpty) {
val (tv, constr) = log.head
tv.constr = constr