summaryrefslogtreecommitdiff
path: root/src/reflect/scala/reflect/macros/Typers.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-10-03 23:09:42 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-10-03 23:56:07 +0200
commit992d255e2fc1ca487a60e38196ec4aa952617b92 (patch)
treeb929ca03652a7e0fff1d4e02b3e28dc15a913887 /src/reflect/scala/reflect/macros/Typers.scala
parent1b2415865984071036c5f61e82a4a7048d4d18ee (diff)
downloadscala-992d255e2fc1ca487a60e38196ec4aa952617b92.tar.gz
scala-992d255e2fc1ca487a60e38196ec4aa952617b92.tar.bz2
scala-992d255e2fc1ca487a60e38196ec4aa952617b92.zip
renames macros.TypeError to TypecheckException
Again, this is not a fatal error, so it should end with an Error, and it should subclass not Throwable, but Exception. Also moved the exception outside the cake to simplify error handling, along the same lines of what've been done for parsing and reification exceptions.
Diffstat (limited to 'src/reflect/scala/reflect/macros/Typers.scala')
-rw-r--r--src/reflect/scala/reflect/macros/Typers.scala26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/reflect/scala/reflect/macros/Typers.scala b/src/reflect/scala/reflect/macros/Typers.scala
index eef6507418..9c4854f89f 100644
--- a/src/reflect/scala/reflect/macros/Typers.scala
+++ b/src/reflect/scala/reflect/macros/Typers.scala
@@ -24,11 +24,11 @@ trait Typers {
* Unlike `enclosingImplicits`, this is a def, which means that it gets recalculated on every invocation,
* so it might change depending on what is going on during macro expansion.
*/
- def openImplicits: List[(Type, Tree)]
+ def openImplicits: List[(Type, Tree)]
/** Typechecks the provided tree against the expected type `pt` in the macro callsite context.
*
- * If `silent` is false, `TypeError` will be thrown in case of a typecheck error.
+ * If `silent` is false, `TypecheckException` will be thrown in case of a typecheck error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Ymacro-debug-verbose.
* Unlike in `inferImplicitValue` and `inferImplicitView`, `silent` is false by default.
@@ -36,26 +36,32 @@ trait Typers {
* Typechecking can be steered with the following optional parameters:
* `withImplicitViewsDisabled` recursively prohibits implicit views (though, implicit vals will still be looked up and filled in), default value is false
* `withMacrosDisabled` recursively prohibits macro expansions and macro-based implicits, default value is false
+ *
+ * @throws [[scala.reflect.macros.TypecheckException]]
*/
def typeCheck(tree: Tree, pt: Type = WildcardType, silent: Boolean = false, withImplicitViewsDisabled: Boolean = false, withMacrosDisabled: Boolean = false): Tree
/** Infers an implicit value of the expected type `pt` in the macro callsite context.
* Optional `pos` parameter provides a position that will be associated with the implicit search.
*
- * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is false, `TypecheckException` will be thrown in case of an inference error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
* Unlike in `typeCheck`, `silent` is true by default.
+ *
+ * @throws [[scala.reflect.macros.TypecheckException]]
*/
def inferImplicitValue(pt: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree
/** Infers an implicit view from the provided tree `tree` of the type `from` to the type `to` in the macro callsite context.
* Optional `pos` parameter provides a position that will be associated with the implicit search.
*
- * If `silent` is false, `TypeError` will be thrown in case of an inference error.
+ * If `silent` is false, `TypecheckException` will be thrown in case of an inference error.
* If `silent` is true, the typecheck is silent and will return `EmptyTree` if an error occurs.
* Such errors don't vanish and can be inspected by turning on -Xlog-implicits.
* Unlike in `typeCheck`, `silent` is true by default.
+ *
+ * @throws [[scala.reflect.macros.TypecheckException]]
*/
def inferImplicitView(tree: Tree, from: Type, to: Type, silent: Boolean = true, withMacrosDisabled: Boolean = false, pos: Position = enclosingPosition): Tree
@@ -72,12 +78,8 @@ trait Typers {
* For more info, read up https://issues.scala-lang.org/browse/SI-5464.
*/
def resetLocalAttrs(tree: Tree): Tree
+}
- /** Represents an error during typechecking
- */
- type TypeError <: Throwable
- val TypeError: TypeErrorExtractor
- abstract class TypeErrorExtractor {
- def unapply(error: TypeError): Option[(Position, String)]
- }
-} \ No newline at end of file
+/** Indicates an error during one of the methods in [[scala.reflect.macros.Typers]].
+ */
+case class TypecheckException(val pos: scala.reflect.api.Position, val msg: String) extends Exception(msg)