summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/symtab
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-03-04 05:22:57 +0000
committerPaul Phillips <paulp@improving.org>2010-03-04 05:22:57 +0000
commit34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec (patch)
treeb2ae69f2731acde0ec4b921cf2e1a73295ea3250 /src/compiler/scala/tools/nsc/symtab
parent65520ac86f5362bfa438c0b9e1a84f1f558e2618 (diff)
downloadscala-34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec.tar.gz
scala-34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec.tar.bz2
scala-34b8e8fcbbb1b11ce81bf69b730abcb78b6699ec.zip
A few yards short of the goal posts attempt at ...
A few yards short of the goal posts attempt at making our usage of Throwable subclasses more consistent. This patch eliminates a lot of ad hoc Exception/Error/etc. creation and various arbitrary choices are rendered slightly less arbitrary. From now on let's try not to use the word "Exception" or "Error" in the names of Throwable subclasses unless they actually derive (and make sense to derive) from Exception or Error. Review by community.
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Scopes.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/StdNames.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/SymbolTable.scala2
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala12
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala33
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala3
-rw-r--r--src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala2
8 files changed, 30 insertions, 28 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index 0ea34235b2..edf2e49f5a 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -103,7 +103,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
// exceptions and other throwables
lazy val ThrowableClass = getClass(sn.Throwable)
lazy val NullPointerExceptionClass = getClass(sn.NPException)
- lazy val NonLocalReturnExceptionClass = getClass(sn.NLRException)
+ lazy val NonLocalReturnControlClass = getClass(sn.NLRControl)
lazy val IndexOutOfBoundsExceptionClass = getClass(sn.IOOBException)
lazy val UninitializedErrorClass = getClass("scala.UninitializedFieldError")
lazy val MatchErrorClass = getClass("scala.MatchError")
diff --git a/src/compiler/scala/tools/nsc/symtab/Scopes.scala b/src/compiler/scala/tools/nsc/symtab/Scopes.scala
index a66e5b6cc3..ca6c93bd1c 100644
--- a/src/compiler/scala/tools/nsc/symtab/Scopes.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Scopes.scala
@@ -326,7 +326,7 @@ trait Scopes {
*/
object EmptyScope extends Scope {
override def enter(e: ScopeEntry) {
- throw new Error("EmptyScope.enter")
+ abort("EmptyScope.enter")
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
index 295dba2b46..98f87ca362 100644
--- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala
+++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala
@@ -416,7 +416,7 @@ trait StdNames extends reflect.generic.StdNames { self: SymbolTable =>
val String : Name
val Throwable : Name
val NPException : Name // NullPointerException
- val NLRException : Name = newTermName("scala.runtime.NonLocalReturnException")
+ val NLRControl : Name = newTermName("scala.runtime.NonLocalReturnControl")
val ValueType : Name
val Serializable : Name
val BeanProperty : Name
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
index 618c601b8f..75902568fa 100644
--- a/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
+++ b/src/compiler/scala/tools/nsc/symtab/SymbolTable.scala
@@ -31,6 +31,8 @@ abstract class SymbolTable extends reflect.generic.Universe
def settings: Settings
def rootLoader: LazyType
def log(msg: AnyRef)
+ def abort(msg: String) = throw new Error(msg)
+ def abort() = throw new Error()
/** Are we compiling for Java SE ? */
def forJVM: Boolean
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 30f006201f..328b9c2311 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -740,7 +740,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
cnt += 1
// allow for two completions:
// one: sourceCompleter to LazyType, two: LazyType to completed type
- if (cnt == 3) throw new Error("no progress in completing " + this + ":" + tp)
+ if (cnt == 3) abort("no progress in completing " + this + ":" + tp)
}
val result = rawInfo
result
@@ -882,7 +882,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
* Not applicable for term symbols.
*/
def typeConstructor: Type =
- throw new Error("typeConstructor inapplicable for " + this)
+ abort("typeConstructor inapplicable for " + this)
/** @M -- tpe vs tpeHK:
* Symbol::tpe creates a TypeRef that has dummy type arguments to get a type of kind *
@@ -963,7 +963,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
else if (this.isTerm)
TypeBounds(NothingClass.tpe, intersectionType(List(this.tpe, SingletonClass.tpe)))
else
- throw new Error("unexpected alias type: "+this)
+ abort("unexpected alias type: "+this)
/** Reset symbol to initial state
*/
@@ -1421,7 +1421,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
(if (isModule) moduleClass else toplevelClass).sourceFile
def sourceFile_=(f: AbstractFile) {
- throw new Error("sourceFile_= inapplicable for " + this)
+ abort("sourceFile_= inapplicable for " + this)
}
def isFromClassFile: Boolean =
@@ -2000,7 +2000,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
override def enclClass: Symbol = this
override def toplevelClass: Symbol = this
override def enclMethod: Symbol = this
- override def owner: Symbol = throw new Error("no-symbol does not have owner")
+ override def owner: Symbol = abort("no-symbol does not have owner")
override def sourceFile: AbstractFile = null
override def ownerChain: List[Symbol] = List()
override def ownersIterator: Iterator[Symbol] = Iterator.empty
@@ -2010,7 +2010,7 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
override def rawInfo: Type = NoType
protected def doCookJavaRawInfo() {}
override def accessBoundary(base: Symbol): Symbol = RootClass
- def cloneSymbolImpl(owner: Symbol): Symbol = throw new Error()
+ def cloneSymbolImpl(owner: Symbol): Symbol = abort()
}
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 10bebc40f8..855e6951d0 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -13,6 +13,7 @@ import ast.TreeGen
import util.{HashSet, Position, NoPosition}
import util.Statistics._
import Flags._
+import scala.util.control.ControlThrowable
/* A standard type pattern match:
case ErrorType =>
@@ -709,7 +710,7 @@ trait Types extends reflect.generic.Types { self: SymbolTable =>
if (sym == btssym) return mid
else if (sym isLess btssym) hi = mid - 1
else if (btssym isLess sym) lo = mid + 1
- else throw new Error()
+ else abort()
}
-1
}
@@ -2531,7 +2532,7 @@ A type's typeSymbol should never be inspected directly.
case tv@TypeVar(_, constr) => tv.applyArgs(args)
case ErrorType => tycon
case WildcardType => tycon // needed for neg/t0226
- case _ => throw new Error(debugString(tycon))
+ case _ => abort(debugString(tycon))
}
/** A creator for type parameterizations
@@ -3128,9 +3129,7 @@ A type's typeSymbol should never be inspected directly.
if ((pre eq NoType) || (pre eq NoPrefix) || !clazz.isClass) mapOver(tp)
//@M! see test pos/tcpoly_return_overriding.scala why mapOver is necessary
else {
- def throwError : Nothing = throw new Error(
- "" + tp + sym.locationString + " cannot be instantiated from " + pre.widen
- )
+ def throwError = abort("" + tp + sym.locationString + " cannot be instantiated from " + pre.widen)
def instParam(ps: List[Symbol], as: List[Type]): Type =
if (ps.isEmpty) throwError
@@ -3547,9 +3546,9 @@ A type's typeSymbol should never be inspected directly.
}
}
- class MissingAliasException extends Exception
- val missingAliasException = new MissingAliasException
- class MissingTypeException extends Exception
+ class MissingAliasControl extends ControlThrowable
+ val missingAliasException = new MissingAliasControl
+ class MissingTypeControl extends ControlThrowable
object adaptToNewRunMap extends TypeMap {
private def adaptToNewRun(pre: Type, sym: Symbol): Symbol = {
@@ -3561,7 +3560,7 @@ A type's typeSymbol should never be inspected directly.
var rebind0 = pre.findMember(sym.name, BRIDGE, 0, true)
if (rebind0 == NoSymbol) {
if (sym.isAliasType) throw missingAliasException
- throw new MissingTypeException // For build manager purposes
+ throw new MissingTypeControl // For build manager purposes
//assert(false, pre+"."+sym+" does no longer exist, phase = "+phase)
}
/** The two symbols have the same fully qualified name */
@@ -3606,9 +3605,9 @@ A type's typeSymbol should never be inspected directly.
if ((pre1 eq pre) && (sym1 eq sym) && (args1 eq args)/* && sym.isExternal*/) tp
else typeRef(pre1, sym1, args1)
} catch {
- case ex: MissingAliasException =>
+ case ex: MissingAliasControl =>
apply(tp.dealias)
- case _: MissingTypeException =>
+ case _: MissingTypeControl =>
NoType
}
}
@@ -4742,7 +4741,7 @@ A type's typeSymbol should never be inspected directly.
res
case TypeVar(_, constr) =>
if (constr.instValid) constr.inst
- else throw new Error("trying to do lub/glb of typevar "+tp)
+ else abort("trying to do lub/glb of typevar "+tp)
case t => t
}
val strippedTypes = ts mapConserve (stripType)
@@ -5119,15 +5118,15 @@ A type's typeSymbol should never be inspected directly.
// Errors and Diagnostics -----------------------------------------------------
- /** An exception signalling a type error */
- class TypeError(var pos: Position, val msg: String) extends java.lang.Error(msg) {
+ /** A throwable signalling a type error */
+ class TypeError(var pos: Position, val msg: String) extends Throwable(msg) with ControlThrowable {
def this(msg: String) = this(NoPosition, msg)
}
- class NoCommonType(tps: List[Type]) extends java.lang.Error(
- "lub/glb of incompatible types: " + tps.mkString("", " and ", ""))
+ class NoCommonType(tps: List[Type]) extends Throwable(
+ "lub/glb of incompatible types: " + tps.mkString("", " and ", "")) with ControlThrowable
- /** An exception signalling a malformed type */
+ /** A throwable signalling a malformed type */
class MalformedType(msg: String) extends TypeError(msg) {
def this(pre: Type, tp: String) = this("malformed type: " + pre + "#" + tp)
}
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
index 745761a065..edf81a97ad 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala
@@ -95,7 +95,8 @@ abstract class ClassfileParser {
parseHeader
this.pool = new ConstantPool
parseClass()
- } catch {
+ }
+ catch {
case e: MissingRequirementError => handleMissing(e)
case e: RuntimeException => handleError(e)
}
diff --git a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
index a1a4545894..92ff741b20 100644
--- a/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
+++ b/src/compiler/scala/tools/nsc/symtab/clr/TypeParser.scala
@@ -42,7 +42,7 @@ abstract class TypeParser {
def parse(typ: MSILType, root: Symbol) {
- def handleError(e: Exception) = {
+ def handleError(e: Throwable) = {
if (settings.debug.value) e.printStackTrace() //debug
throw new IOException("type '" + typ.FullName + "' is broken\n(" + e.getMessage() + ")")
}