summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2013-05-04 16:18:23 +0200
committerEugene Burmako <xeno.by@gmail.com>2013-05-11 20:15:12 +0200
commit4e64a2731d6e4c27e2fd4c75559e118708e79ad5 (patch)
tree0e2d0051f4ffd2e60913c2d0246aa4cde7b6f7c3 /src/compiler/scala/tools/reflect/ToolBoxFactory.scala
parent3edde2727bad9b00cbaf5475f5bf234f08c26cbd (diff)
downloadscala-4e64a2731d6e4c27e2fd4c75559e118708e79ad5.tar.gz
scala-4e64a2731d6e4c27e2fd4c75559e118708e79ad5.tar.bz2
scala-4e64a2731d6e4c27e2fd4c75559e118708e79ad5.zip
[nomaster] removes duplication in inferImplicitValue
Shame-driven development at its best.
Diffstat (limited to 'src/compiler/scala/tools/reflect/ToolBoxFactory.scala')
-rw-r--r--src/compiler/scala/tools/reflect/ToolBoxFactory.scala22
1 files changed, 1 insertions, 21 deletions
diff --git a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
index b9968eedef..4b5dcadfa2 100644
--- a/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
+++ b/src/compiler/scala/tools/reflect/ToolBoxFactory.scala
@@ -180,28 +180,8 @@ abstract class ToolBoxFactory[U <: JavaUniverse](val u: U) { factorySelf =>
def inferImplicit(tree: Tree, pt: Type, isView: Boolean, silent: Boolean, withMacrosDisabled: Boolean, pos: Position): Tree =
transformDuringTyper(tree, withImplicitViewsDisabled = false, withMacrosDisabled = withMacrosDisabled)(
(currentTyper, tree) => {
- import scala.tools.nsc.typechecker.DivergentImplicit
trace("inferring implicit %s (macros = %s): ".format(if (isView) "view" else "value", !withMacrosDisabled))(showAttributed(pt, true, true, settings.Yshowsymkinds.value))
- val context = currentTyper.context
- def fail(reason: Option[String]) = {
- debuglog("reflective implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- if (!silent) {
- if (context.hasErrors) throw ToolBoxError("reflective implicit search has failed: %s".format(context.errBuffer.head.errMsg))
- else throw ToolBoxError(reason getOrElse "reflective implicit search has failed. to find out the reason, turn on -Xlog-implicits")
- }
- EmptyTree
- }
- try {
- analyzer.inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context = context, saveAmbiguousDivergent = !silent, pos = pos) match {
- case failure if failure.tree.isEmpty => fail(None)
- case success => success.tree
- }
- } catch {
- case ex: DivergentImplicit =>
- if (settings.Xdivergence211.value)
- debuglog("this shouldn't happen. DivergentImplicit exception has been thrown with -Xdivergence211 turned on: "+ex)
- fail(Some("divergent implicit expansion"))
- }
+ analyzer.inferImplicit(tree, pt, isView, currentTyper.context, silent, withMacrosDisabled, pos, (pos, msg) => throw ToolBoxError(msg))
})
def compile(expr0: Tree): () => Any = {