diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/reflect/macros/runtime/Typers.scala | 9 | ||||
-rw-r--r-- | src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 10 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/compiler/scala/reflect/macros/runtime/Typers.scala b/src/compiler/scala/reflect/macros/runtime/Typers.scala index 30370119fe..07d18eabe6 100644 --- a/src/compiler/scala/reflect/macros/runtime/Typers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Typers.scala @@ -54,10 +54,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") - context.firstError match { - case Some(err) => throw new TypecheckException(err.errPos, err.errMsg) - case None => universe.EmptyTree + if (!silent) { + val err = context.firstError + val errPos = err.map(_.errPos).getOrElse(pos) + val errMsg = err.map(_.errMsg).getOrElse("implicit search has failed. to find out the reason, turn on -Xlog-implicits") + throw new TypecheckException(errPos, errMsg) } + universe.EmptyTree case success => success.tree } diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala index 7f7bcd70d2..8512c32361 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -183,12 +183,10 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => trace("inferring implicit %s (macros = %s): ".format(if (isView) "view" else "value", !withMacrosDisabled))(showAttributed(pt, true, true, settings.Yshowsymkinds.value)) val context = currentTyper.context val result = analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos) - if (result.isFailure) { - // @H: what's the point of tracing an empty tree? - trace("implicit search has failed. to find out the reason, turn on -Xlog-implicits: ")(result.tree) - context.firstError foreach { err => - throw ToolBoxError("reflective implicit search has failed: %s".format(err.errMsg)) - } + if (result.isFailure && !silent) { + val err = context.firstError + val errMsg = err.map(_.errMsg).getOrElse("reflective implicit search has failed. to find out the reason, turn on -Xlog-implicits") + throw ToolBoxError(errMsg) } result.tree }) |