diff options
-rw-r--r-- | src/compiler/scala/reflect/macros/runtime/Typers.scala | 5 | ||||
-rw-r--r-- | src/compiler/scala/tools/reflect/ToolBoxFactory.scala | 5 | ||||
-rw-r--r-- | test/files/run/t7047.check | 0 | ||||
-rw-r--r-- | test/files/run/t7047/Impls_Macros_1.scala | 19 | ||||
-rw-r--r-- | test/files/run/t7047/Test_2.scala | 3 |
5 files changed, 30 insertions, 2 deletions
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 diff --git a/test/files/run/t7047.check b/test/files/run/t7047.check new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/files/run/t7047.check diff --git a/test/files/run/t7047/Impls_Macros_1.scala b/test/files/run/t7047/Impls_Macros_1.scala new file mode 100644 index 0000000000..2992e3efe4 --- /dev/null +++ b/test/files/run/t7047/Impls_Macros_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +class Foo + +object Macros { + def impl(c: Context) = { + import c.universe._ + try { + c.inferImplicitValue(typeOf[Foo], silent = false) + c.abort(c.enclosingPosition, "silent=false is not working") + } catch { + case _: Exception => + } + c.literalNull + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t7047/Test_2.scala b/test/files/run/t7047/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/run/t7047/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +}
\ No newline at end of file |