summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-10-09 08:54:10 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-10-09 08:54:10 -0700
commit7ca76c8b3bef2d46333b4571806b126533239cda (patch)
treeb8e1505229add5ec116ca7ff682078c8e5c64c37 /src/compiler
parent859ec02495993f225647df50397b042a3172351b (diff)
parent49dcb8ff33483949cecce671a2d87676cefa457f (diff)
downloadscala-7ca76c8b3bef2d46333b4571806b126533239cda.tar.gz
scala-7ca76c8b3bef2d46333b4571806b126533239cda.tar.bz2
scala-7ca76c8b3bef2d46333b4571806b126533239cda.zip
Merge pull request #1458 from scalamacros/pullrequest/reflection
Another reflection bomb
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Parsers.scala2
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Typers.scala10
-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.scala10
-rw-r--r--src/compiler/scala/reflect/reify/package.scala4
-rw-r--r--src/compiler/scala/reflect/reify/utils/SymbolTables.scala2
-rw-r--r--src/compiler/scala/tools/reflect/MacroImplementations.scala2
-rw-r--r--src/compiler/scala/tools/util/PathResolver.scala2
9 files changed, 29 insertions, 35 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Parsers.scala b/src/compiler/scala/reflect/macros/runtime/Parsers.scala
index ab9b94ec9f..566bcde73d 100644
--- a/src/compiler/scala/reflect/macros/runtime/Parsers.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Parsers.scala
@@ -19,6 +19,6 @@ trait Parsers {
} catch {
case ToolBoxError(msg, cause) =>
// todo. provide a position
- throw new ParseError(universe.NoPosition, msg)
+ throw new ParseException(universe.NoPosition, msg)
}
}
diff --git a/src/compiler/scala/reflect/macros/runtime/Typers.scala b/src/compiler/scala/reflect/macros/runtime/Typers.scala
index 9fa8567ada..be70181126 100644
--- a/src/compiler/scala/reflect/macros/runtime/Typers.scala
+++ b/src/compiler/scala/reflect/macros/runtime/Typers.scala
@@ -25,7 +25,7 @@ trait Typers {
result
case error @ universe.analyzer.SilentTypeError(_) =>
macroLogVerbose(error.err.errMsg)
- if (!silent) throw new universe.TypeError(error.err.errPos, error.err.errMsg)
+ if (!silent) throw new TypecheckException(error.err.errPos, error.err.errMsg)
universe.EmptyTree
})
}
@@ -49,19 +49,13 @@ trait Typers {
wrapper(universe.analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos)) match {
case failure if failure.tree.isEmpty =>
macroLogVerbose("implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- if (context.hasErrors) throw new universe.TypeError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
+ if (context.hasErrors) throw new TypecheckException(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
universe.EmptyTree
case success =>
success.tree
}
}
- type TypeError = universe.TypeError
-
- object TypeError extends TypeErrorExtractor {
- def unapply(error: TypeError): Option[(Position, String)] = Some((error.pos, error.msg))
- }
-
def resetAllAttrs(tree: Tree): Tree = universe.resetAllAttrs(tree)
def resetLocalAttrs(tree: Tree): Tree = universe.resetLocalAttrs(tree)
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 7db6394734..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}
+import scala.reflect.macros.{ReificationException, UnexpectedReificationException, TypecheckException}
import scala.reflect.macros.runtime.Context
abstract class Taggers {
@@ -65,22 +65,22 @@ abstract class Taggers {
translatingReificationErrors(materializer)
}
try c.typeCheck(result)
- catch { case terr @ c.TypeError(pos, msg) => failTag(result, terr) }
+ catch { case terr @ TypecheckException(pos, msg) => failTag(result, terr) }
}
def materializeExpr(universe: Tree, mirror: Tree, expr: Tree): Tree = {
val result = translatingReificationErrors(c.reifyTree(universe, mirror, expr))
try c.typeCheck(result)
- catch { case terr @ c.TypeError(pos, msg) => failExpr(result, terr) }
+ catch { case terr @ TypecheckException(pos, msg) => failExpr(result, terr) }
}
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/reflect/reify/utils/SymbolTables.scala b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala
index 3ec43c863d..dbb0836e0a 100644
--- a/src/compiler/scala/reflect/reify/utils/SymbolTables.scala
+++ b/src/compiler/scala/reflect/reify/utils/SymbolTables.scala
@@ -28,7 +28,7 @@ trait SymbolTables {
symtab.get(sym) match {
case Some(FreeDef(_, name, _, _, _)) => name
case Some(SymDef(_, name, _, _)) => name
- case None => EmptyTermName
+ case None => nme.EMPTY
}
def symAliases(sym: Symbol): List[TermName] =
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