From b4da864247ccaaee4f987fbf433b312e1d744a8f Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 23 Feb 2013 14:49:38 +0100 Subject: [nomaster] SI-7047 fixes silent for c.inferImplicitXXX silent = true now throws a TypecheckException even if we don't know why an implicit search has failed (i.e. if context.hasErrors is false). NOTE: this commit is a part of a pull request for 2.10.x, which makes sense of implicit macros. Everything in that pull request is [nomaster] due to one reason or another. This commit would work equally well in both 2.10.x and master, but I'm marking it as [nomaster] as well, because I'm anyway going to resubmit the whole pull request into master soon, so there's no reason to introduce additional confusion. --- src/compiler/scala/reflect/macros/runtime/Typers.scala | 5 ++++- src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/reflect/macros/runtime/Typers.scala b/src/compiler/scala/reflect/macros/runtime/Typers.scala index 8dc9bdeb7a..7cfee2041c 100644 --- a/src/compiler/scala/reflect/macros/runtime/Typers.scala +++ b/src/compiler/scala/reflect/macros/runtime/Typers.scala @@ -52,7 +52,10 @@ 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 TypecheckException(context.errBuffer.head.errPos, context.errBuffer.head.errMsg) + if (!silent) { + if (context.hasErrors) throw new TypecheckException(context.errBuffer.head.errPos, context.errBuffer.head.errMsg) + else throw new TypecheckException(pos, "implicit search has failed. to find out the reason, turn on -Xlog-implicits") + } 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 c05c59d5ff..acfc86c1ac 100644 --- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala +++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala @@ -185,7 +185,10 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf => analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos) match { case failure if failure.tree.isEmpty => trace("implicit search has failed. to find out the reason, turn on -Xlog-implicits: ")(failure.tree) - if (context.hasErrors) throw ToolBoxError("reflective implicit search has failed: %s".format(context.errBuffer.head.errMsg)) + if (!silent) { + if (context.hasErrors) throw ToolBoxError("reflective implicit search has failed: %s".format(context.errBuffer.head.errMsg)) + else throw new ToolBoxError("reflective implicit search has failed. to find out the reason, turn on -Xlog-implicits") + } EmptyTree case success => success.tree -- cgit v1.2.3