summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2011-12-07 16:34:26 +0100
committerEugene Burmako <xeno.by@gmail.com>2011-12-07 16:36:23 +0100
commit1f8d642eb9f7b0787087212607e012566a699c04 (patch)
tree345200749a18f0bd9de77502596917631cb2a335
parent6a33a206196d95d931b5569b466275c19426e5b2 (diff)
downloadscala-1f8d642eb9f7b0787087212607e012566a699c04.tar.gz
scala-1f8d642eb9f7b0787087212607e012566a699c04.tar.bz2
scala-1f8d642eb9f7b0787087212607e012566a699c04.zip
Reflective compiler now crashes properly
Adjust toolbox to escalate errors reported during reflective compilation. Without this functionality, errors get swallowed and lead to weirdness like https://issues.scala-lang.org/browse/SI-5274. The only meaningful part of the output in the bug report linked above is the first line. Subsequent stack trace is at best useless and at worst misleading. Now the error report is much more sane: https://gist.github.com/1443232 Review by @odersky.
-rw-r--r--src/compiler/scala/reflect/runtime/ToolBoxes.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/scala/reflect/runtime/ToolBoxes.scala b/src/compiler/scala/reflect/runtime/ToolBoxes.scala
index e617239398..02fcf7b448 100644
--- a/src/compiler/scala/reflect/runtime/ToolBoxes.scala
+++ b/src/compiler/scala/reflect/runtime/ToolBoxes.scala
@@ -88,7 +88,13 @@ trait ToolBoxes extends { self: Universe =>
def runExpr(expr: Tree): Any = {
val etpe = expr.tpe
val fvs = (expr filter isFree map (_.symbol)).distinct
+
+ reporter.reset()
val className = compileExpr(expr, fvs)
+ if (reporter.hasErrors) {
+ throw new Error("reflective compilation has failed")
+ }
+
if (settings.debug.value) println("generated: "+className)
val jclazz = jClass.forName(moduleFileName(className), true, classLoader)
val jmeth = jclazz.getDeclaredMethods.find(_.getName == wrapperMethodName).get