summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-02-23 14:49:38 +0100
committerEugene Burmako <xeno.by@gmail.com>2013-05-12 22:19:02 +0200
commitb1538804043bdd7036a6378a9146b685db03a4ba (patch)
tree27981ea22364fc0d0fd6a60bdc8db5f8321cd722 /src/compiler
parentc539ae2f56fe9f565cffb4afd6ab131bda89acb7 (diff)
downloadscala-b1538804043bdd7036a6378a9146b685db03a4ba.tar.gz
scala-b1538804043bdd7036a6378a9146b685db03a4ba.tar.bz2
scala-b1538804043bdd7036a6378a9146b685db03a4ba.zip
SI-7047 fixes silent for c.inferImplicitXXX
This is a port of https://github.com/scala/scala/commit/b4da864247 from 2.10.x.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/reflect/macros/runtime/Typers.scala9
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala10
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
})