From 76dfe52fff10dd11dece7345adb23baf1131c704 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 2 Feb 2011 11:25:52 +0000 Subject: 2nd attempt to survive divergent implicits in t... 2nd attempt to survive divergent implicits in the presentation compiler. --- src/compiler/scala/tools/nsc/interactive/Global.scala | 19 ++++++++++--------- .../scala/tools/nsc/typechecker/Implicits.scala | 5 ++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index f06642eed4..4f9841cf2a 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -14,6 +14,7 @@ import scala.tools.nsc.reporters._ import scala.tools.nsc.symtab._ import scala.tools.nsc.ast._ import scala.tools.nsc.io.Pickler._ +import scala.tools.nsc.typechecker.DivergentImplicit import scala.annotation.tailrec import scala.reflect.generic.Flags.LOCKED @@ -672,14 +673,9 @@ self => */ def viewApply(view: SearchResult): Tree = { assert(view.tree != EmptyTree) - try { - analyzer.newTyper(context.makeImplicit(reportAmbiguousErrors = false)) - .typed(Apply(view.tree, List(tree)) setPos tree.pos) - } catch { - case ex: TypeError => - debugLog("type error caught: "+ex) - EmptyTree - } + analyzer.newTyper(context.makeImplicit(reportAmbiguousErrors = false)) + .typed(Apply(view.tree, List(tree)) setPos tree.pos) + .onTypeError(EmptyTree) } /** Names containing $ are not valid completions. */ @@ -831,7 +827,12 @@ self => def onTypeError(alt: => T) = try { op } catch { - case ex: TypeError => alt + case ex: TypeError => + debugLog("type error caught: "+ex) + alt + case ex: DivergentImplicit => + debugLog("divergent implicit caught: "+ex) + alt } } } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 55c24c3b5f..6d36c77b28 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -996,7 +996,6 @@ trait Implicits { } } } - - private class DivergentImplicit extends Exception - private val DivergentImplicit = new DivergentImplicit } +class DivergentImplicit extends Exception +object DivergentImplicit extends DivergentImplicit -- cgit v1.2.3