summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-10-03 23:13:04 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-10-03 23:56:12 +0200
commitfb515bca0549cbc84a40b23889d1f038bcb0ef3a (patch)
tree47c27a7e0c292340f9b6ee765baefeb2e0bfded2
parent992d255e2fc1ca487a60e38196ec4aa952617b92 (diff)
downloadscala-fb515bca0549cbc84a40b23889d1f038bcb0ef3a.tar.gz
scala-fb515bca0549cbc84a40b23889d1f038bcb0ef3a.tar.bz2
scala-fb515bca0549cbc84a40b23889d1f038bcb0ef3a.zip
renames macros.ReificationError to ReificationException
And again, this is not a fatal error, so it should end with an Error, and it should subclass not Throwable, but Exception.
-rw-r--r--src/compiler/scala/reflect/reify/Errors.scala22
-rw-r--r--src/compiler/scala/reflect/reify/Reifier.scala10
-rw-r--r--src/compiler/scala/reflect/reify/Taggers.scala6
-rw-r--r--src/compiler/scala/reflect/reify/package.scala4
-rw-r--r--src/compiler/scala/tools/reflect/MacroImplementations.scala2
-rw-r--r--src/compiler/scala/tools/util/PathResolver.scala2
-rw-r--r--src/reflect/scala/reflect/macros/Reifiers.scala12
7 files changed, 33 insertions, 25 deletions
diff --git a/src/compiler/scala/reflect/reify/Errors.scala b/src/compiler/scala/reflect/reify/Errors.scala
index 73c13901b6..c25112941c 100644
--- a/src/compiler/scala/reflect/reify/Errors.scala
+++ b/src/compiler/scala/reflect/reify/Errors.scala
@@ -1,7 +1,7 @@
package scala.reflect.reify
-import scala.reflect.macros.ReificationError
-import scala.reflect.macros.UnexpectedReificationError
+import scala.reflect.macros.ReificationException
+import scala.reflect.macros.UnexpectedReificationException
trait Errors {
self: Reifier =>
@@ -19,17 +19,17 @@ trait Errors {
def CannotReifyType(tpe: Type) = {
val msg = "implementation restriction: cannot reify type %s (%s)".format(tpe, tpe.kind)
- throw new ReificationError(defaultErrorPosition, msg)
+ throw new ReificationException(defaultErrorPosition, msg)
}
def CannotReifySymbol(sym: Symbol) = {
val msg = "implementation restriction: cannot reify symbol %s (%s)".format(sym, sym.accurateKindString)
- throw new ReificationError(defaultErrorPosition, msg)
+ throw new ReificationException(defaultErrorPosition, msg)
}
def CannotReifyWeakType(details: Any) = {
val msg = "cannot create a TypeTag" + details
- throw new ReificationError(defaultErrorPosition, msg)
+ throw new ReificationException(defaultErrorPosition, msg)
}
def CannotConvertManifestToTagWithoutScalaReflect(tpe: Type, manifestInScope: Tree) = {
@@ -37,7 +37,7 @@ trait Errors {
|to create a type tag here, it is necessary to interoperate with the manifest `$manifestInScope` in scope.
|however manifest -> typetag conversion requires Scala reflection, which is not present on the classpath.
|to proceed put scala-reflect.jar on your compilation classpath and recompile.""".trim.stripMargin
- throw new ReificationError(defaultErrorPosition, msg)
+ throw new ReificationException(defaultErrorPosition, msg)
}
def CannotReifyRuntimeSplice(tree: Tree) = {
@@ -46,7 +46,7 @@ trait Errors {
|cross-stage evaluations need to be invoked explicitly, so we're showing you this error.
|if you're sure this is not an oversight, add scala-compiler.jar to the classpath,
|import `scala.tools.reflect.Eval` and call `<your expr>.eval` instead.""".trim.stripMargin
- throw new ReificationError(tree.pos, msg)
+ throw new ReificationException(tree.pos, msg)
}
// unexpected errors: these can never happen under normal conditions unless there's a bug in the compiler (or in a compiler plugin or in a macro)
@@ -54,21 +54,21 @@ trait Errors {
def CannotReifyUntypedPrefix(prefix: Tree) = {
val msg = "internal error: untyped prefixes are not supported, consider typechecking the prefix before passing it to the reifier"
- throw new UnexpectedReificationError(defaultErrorPosition, msg)
+ throw new UnexpectedReificationException(defaultErrorPosition, msg)
}
def CannotReifyUntypedReifee(reifee: Any) = {
val msg = "internal error: untyped trees are not supported, consider typechecking the reifee before passing it to the reifier"
- throw new UnexpectedReificationError(defaultErrorPosition, msg)
+ throw new UnexpectedReificationException(defaultErrorPosition, msg)
}
def CannotReifyErroneousPrefix(prefix: Tree) = {
val msg = "internal error: erroneous prefixes are not supported, make sure that your prefix has typechecked successfully before passing it to the reifier"
- throw new UnexpectedReificationError(defaultErrorPosition, msg)
+ throw new UnexpectedReificationException(defaultErrorPosition, msg)
}
def CannotReifyErroneousReifee(reifee: Any) = {
val msg = "internal error: erroneous reifees are not supported, make sure that your reifee has typechecked successfully before passing it to the reifier"
- throw new UnexpectedReificationError(defaultErrorPosition, msg)
+ throw new UnexpectedReificationException(defaultErrorPosition, msg)
}
}
diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala
index f48fcd8ada..47669f57b0 100644
--- a/src/compiler/scala/reflect/reify/Reifier.scala
+++ b/src/compiler/scala/reflect/reify/Reifier.scala
@@ -1,8 +1,8 @@
package scala.reflect.reify
import scala.tools.nsc.Global
-import scala.reflect.macros.ReificationError
-import scala.reflect.macros.UnexpectedReificationError
+import scala.reflect.macros.ReificationException
+import scala.reflect.macros.UnexpectedReificationException
import scala.reflect.reify.utils.Utils
/** Given a tree or a type, generate a tree that when executed at runtime produces the original tree or type.
@@ -132,12 +132,12 @@ abstract class Reifier extends States
untyped
} catch {
- case ex: ReificationError =>
+ case ex: ReificationException =>
throw ex
- case ex: UnexpectedReificationError =>
+ case ex: UnexpectedReificationException =>
throw ex
case ex: Throwable =>
- throw new UnexpectedReificationError(defaultErrorPosition, "reification crashed", ex)
+ throw new UnexpectedReificationException(defaultErrorPosition, "reification crashed", ex)
}
}
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala
index 513ce020cc..cbaee41890 100644
--- a/src/compiler/scala/reflect/reify/Taggers.scala
+++ b/src/compiler/scala/reflect/reify/Taggers.scala
@@ -1,6 +1,6 @@
package scala.reflect.reify
-import scala.reflect.macros.{ReificationError, UnexpectedReificationError, TypecheckException}
+import scala.reflect.macros.{ReificationException, UnexpectedReificationException, TypecheckException}
import scala.reflect.macros.runtime.Context
abstract class Taggers {
@@ -77,10 +77,10 @@ abstract class Taggers {
private def translatingReificationErrors(materializer: => Tree): Tree = {
try materializer
catch {
- case ReificationError(pos, msg) =>
+ case ReificationException(pos, msg) =>
c.error(pos.asInstanceOf[c.Position], msg) // this cast is a very small price for the sanity of exception handling
EmptyTree
- case UnexpectedReificationError(pos, err, cause) if cause != null =>
+ case UnexpectedReificationException(pos, err, cause) if cause != null =>
throw cause
}
}
diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala
index 5a23ab7214..55f8684df2 100644
--- a/src/compiler/scala/reflect/reify/package.scala
+++ b/src/compiler/scala/reflect/reify/package.scala
@@ -1,7 +1,7 @@
package scala.reflect
import scala.language.implicitConversions
-import scala.reflect.macros.{Context, ReificationError, UnexpectedReificationError}
+import scala.reflect.macros.{Context, ReificationException, UnexpectedReificationException}
import scala.tools.nsc.Global
package object reify {
@@ -53,7 +53,7 @@ package object reify {
if (tpe.isSpliceable) {
val classTagInScope = typer0.resolveClassTag(enclosingMacroPosition, tpe, allowMaterialization = false)
if (!classTagInScope.isEmpty) return Select(classTagInScope, nme.runtimeClass)
- if (concrete) throw new ReificationError(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
+ if (concrete) throw new ReificationException(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe))
}
tpe.normalize match {
diff --git a/src/compiler/scala/tools/reflect/MacroImplementations.scala b/src/compiler/scala/tools/reflect/MacroImplementations.scala
index 48a4811744..86cd845c54 100644
--- a/src/compiler/scala/tools/reflect/MacroImplementations.scala
+++ b/src/compiler/scala/tools/reflect/MacroImplementations.scala
@@ -1,6 +1,6 @@
package scala.tools.reflect
-import scala.reflect.macros.{ReificationError, UnexpectedReificationError}
+import scala.reflect.macros.{ReificationException, UnexpectedReificationException}
import scala.reflect.macros.runtime.Context
import scala.collection.mutable.ListBuffer
import scala.collection.mutable.Stack
diff --git a/src/compiler/scala/tools/util/PathResolver.scala b/src/compiler/scala/tools/util/PathResolver.scala
index f6dc92f96e..7cf3586d3d 100644
--- a/src/compiler/scala/tools/util/PathResolver.scala
+++ b/src/compiler/scala/tools/util/PathResolver.scala
@@ -195,7 +195,7 @@ class PathResolver(settings: Settings, context: JavaContext) {
def scalaExtDirs = cmdLineOrElse("extdirs", Defaults.scalaExtDirs)
/** Scaladoc doesn't need any bootstrapping, otherwise will create errors such as:
* [scaladoc] ../scala-trunk/src/reflect/scala/reflect/macros/Reifiers.scala:89: error: object api is not a member of package reflect
- * [scaladoc] case class ReificationError(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
+ * [scaladoc] case class ReificationException(val pos: reflect.api.PositionApi, val msg: String) extends Throwable(msg)
* [scaladoc] ^
* because the bootstrapping will look at the sourcepath and create package "reflect" in "<root>"
* and then when typing relative names, instead of picking <root>.scala.relect, typedIdentifier will pick up the
diff --git a/src/reflect/scala/reflect/macros/Reifiers.scala b/src/reflect/scala/reflect/macros/Reifiers.scala
index ed31663c68..0022a488b9 100644
--- a/src/reflect/scala/reflect/macros/Reifiers.scala
+++ b/src/reflect/scala/reflect/macros/Reifiers.scala
@@ -76,6 +76,14 @@ trait Reifiers {
// made these guys non path-dependent, otherwise exception handling quickly becomes a mess
-case class ReificationError(val pos: scala.reflect.api.Position, val msg: String) extends Throwable(msg)
+/** Indicates an expected error during one of the `reifyXXX` methods in [[scala.reflect.macros.Reifiers]].
+ * Such errors represent one of the standard ways for reification to go wrong, e.g.
+ * an attempt to create a `TypeTag` from a weak type.
+ */
+case class ReificationException(val pos: scala.reflect.api.Position, val msg: String) extends Exception(msg)
-case class UnexpectedReificationError(val pos: scala.reflect.api.Position, val msg: String, val cause: Throwable = null) extends Throwable(msg, cause)
+/** Indicates an unexpected expected error during one of the `reifyXXX` methods in [[scala.reflect.macros.Reifiers]].
+ * Such errors wrap random crashes in reification logic and are distinguished from expected [[scala.reflect.macros.ReificationException]]s
+ * so that the latter can be reported as compilation errors, while the former manifest themselves as compiler crashes.
+ */
+case class UnexpectedReificationException(val pos: scala.reflect.api.Position, val msg: String, val cause: Throwable = null) extends Exception(msg, cause)