summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 722440349a..793b85da18 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1133,16 +1133,27 @@ trait Implicits {
* An EmptyTree is returned if materialization fails.
*/
private def tagOfType(pre: Type, tp: Type, tagClass: Symbol): SearchResult = {
- def success(arg: Tree) =
+ def success(arg: Tree) = {
+ def isMacroException(msg: String): Boolean =
+ // [Eugene] very unreliable, ask Hubert about a better way
+ msg contains "exception during macro expansion"
+
+ def processMacroExpansionError(pos: Position, msg: String): SearchResult = {
+ // giving up and reporting all macro exceptions regardless of their source
+ // this might lead to an avalanche of errors if one of your implicit macros misbehaves
+ if (isMacroException(msg)) context.error(pos, msg)
+ failure(arg, "failed to typecheck the materialized tag: %n%s".format(msg), pos)
+ }
+
try {
val tree1 = typed(atPos(pos.focus)(arg))
- def isErroneous = tree exists (_.isErroneous)
- if (context.hasErrors) failure(tp, "failed to typecheck the materialized typetag: %n%s".format(context.errBuffer.head.errMsg), context.errBuffer.head.errPos)
+ if (context.hasErrors) processMacroExpansionError(context.errBuffer.head.errPos, context.errBuffer.head.errMsg)
else new SearchResult(tree1, EmptyTreeTypeSubstituter)
} catch {
case ex: TypeError =>
- failure(arg, "failed to typecheck the materialized typetag: %n%s".format(ex.msg), ex.pos)
+ processMacroExpansionError(ex.pos, ex.msg)
}
+ }
val prefix = (
// ClassTags only exist for scala.reflect.mirror, so their materializer