From b1538804043bdd7036a6378a9146b685db03a4ba Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 23 Feb 2013 14:49:38 +0100 Subject: SI-7047 fixes silent for c.inferImplicitXXX This is a port of https://github.com/scala/scala/commit/b4da864247 from 2.10.x. --- src/compiler/scala/reflect/macros/runtime/Typers.scala | 9 ++++++--- src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 10 ++++------ 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'src/compiler') 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 }) -- cgit v1.2.3