diff options
author | Miles Sabin <miles@milessabin.com> | 2009-07-15 13:01:43 +0000 |
---|---|---|
committer | Miles Sabin <miles@milessabin.com> | 2009-07-15 13:01:43 +0000 |
commit | 69e1ddb55a7f122715dbed337de73f595ae00dc3 (patch) | |
tree | c545190e2d2a79070ac49e76886bdca34f94bdba /src/compiler | |
parent | 370817ac9736f67775a150f679bb5a4c01356ecb (diff) | |
download | scala-69e1ddb55a7f122715dbed337de73f595ae00dc3.tar.gz scala-69e1ddb55a7f122715dbed337de73f595ae00dc3.tar.bz2 scala-69e1ddb55a7f122715dbed337de73f595ae00dc3.zip |
Added ControlException marker trait and update ...
Added ControlException marker trait and update various exceptions to
mix it in; the typer now correctly propagates ControlExceptions rather
than reporting them; the IDE reports attempts to log ControlExceptions;
Global.signalDone no longer leaks ValidateErrors back into the typer;
the set of compiler options offered by the IDE has been updated.
Diffstat (limited to 'src/compiler')
5 files changed, 28 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala index a8f6853853..d247134fd6 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/MarkupParsers.scala @@ -7,6 +7,7 @@ package scala.tools.nsc.ast.parser import scala.collection.mutable +import scala.util.control.ControlException import scala.tools.nsc.util.{Position,NoPosition,SourceFile,CharArrayReader} import scala.xml.{Text, TextBuffer} import SourceFile.{SU,LF} @@ -18,15 +19,15 @@ import scala.annotation.switch * @version 1.0 */ trait MarkupParsers {self: Parsers => - case object MissingEndTagException extends RuntimeException { + case object MissingEndTagException extends RuntimeException with ControlException { override def getMessage = "start tag was here: " } - case object ConfusedAboutBracesException extends RuntimeException { + case object ConfusedAboutBracesException extends RuntimeException with ControlException { override def getMessage = " I encountered a '}' where I didn't expect one, maybe this tag isn't closed <" } - case object TruncatedXML extends RuntimeException { + case object TruncatedXML extends RuntimeException with ControlException { override def getMessage = "input ended while parsing XML" } diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index d264632bd5..0782639ac5 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -1,6 +1,7 @@ package scala.tools.nsc.interactive import scala.concurrent.SyncVar +import scala.util.control.ControlException import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.util.{SourceFile, Position, WorkScheduler} import scala.tools.nsc.symtab._ @@ -104,8 +105,8 @@ trait CompilerControl { self: Global => // ---------------- Interpreted exeptions ------------------- - class CancelActionReq extends Exception - class FreshRunReq extends Exception - class ShutdownReq extends Exception + class CancelActionReq extends Exception with ControlException + class FreshRunReq extends Exception with ControlException + class ShutdownReq extends Exception with ControlException } diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index 51ba19951e..72415b5d7b 100755 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -4,6 +4,7 @@ import java.io.{ PrintWriter, StringWriter } import scala.collection.mutable.{LinkedHashMap, SynchronizedMap} import scala.concurrent.SyncVar +import scala.util.control.ControlException import scala.tools.nsc.io.AbstractFile import scala.tools.nsc.util.{SourceFile, Position, RangePosition, OffsetPosition, NoPosition, WorkScheduler} import scala.tools.nsc.reporters._ @@ -77,11 +78,19 @@ self => throw new TyperResult(located) } val typerRun = currentTyperRun - pollForWork() - if (typerRun != currentTyperRun) { - integrateNew() - throw new FreshRunReq - } + + while(true) + try { + pollForWork() + if (typerRun == currentTyperRun) + return + + integrateNew() + throw new FreshRunReq + } catch { + case ex : ValidateError => // Ignore, this will have been reported elsewhere + case t : Throwable => throw t + } } } @@ -421,9 +430,8 @@ self => } } - class TyperResult(val tree: Tree) extends Exception + class TyperResult(val tree: Tree) extends Exception with ControlException assert(globalPhase.id == 0) - } diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 7565b20c56..ce16b55001 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -7,6 +7,7 @@ package scala.tools.nsc.typechecker import scala.tools.nsc.util.{Position, NoPosition} import scala.collection.mutable.ListBuffer +import scala.util.control.ControlException import symtab.Flags._ /** This trait ... @@ -77,7 +78,7 @@ trait Infer { //todo: remove comments around following privates; right now they cause an IllegalAccess // error when built with scalac - /*private*/ class NoInstance(msg: String) extends RuntimeException(msg) + /*private*/ class NoInstance(msg: String) extends RuntimeException(msg) with ControlException /*private*/ class DeferredNoInstance(getmsg: () => String) extends NoInstance("") { override def getMessage(): String = getmsg() diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f576c17ad1..b1ed6da208 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -11,7 +11,9 @@ package scala.tools.nsc.typechecker import scala.collection.mutable.{HashMap, ListBuffer} +import scala.util.control.ControlException import scala.compat.Platform.currentTime +import scala.tools.nsc.interactive.RangePositions import scala.tools.nsc.util.{HashSet, Position, Set, NoPosition, SourceFile} import symtab.Flags._ import util.HashSet @@ -3735,7 +3737,6 @@ trait Typers { self: Analyzer => * @return ... */ def typed(tree: Tree, mode: Int, pt: Type): Tree = { - import scala.tools.nsc.interactive.CompilerControl def dropExistential(tp: Type): Type = tp match { case ExistentialType(tparams, tpe) => @@ -3767,7 +3768,7 @@ trait Typers { self: Analyzer => if (phase.id <= currentRun.typerPhase.id) signalDone(context.asInstanceOf[analyzer.Context], tree, result) result } catch { - case ex: CompilerControl#FreshRunReq => throw ex + case ex: ControlException => throw ex case ex: TypeError => tree.tpe = null //Console.println("caught "+ex+" in typed");//DEBUG |