diff options
author | Martin Odersky <odersky@gmail.com> | 2009-10-27 13:01:17 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2009-10-27 13:01:17 +0000 |
commit | d4c63b2af19fb48730b3c3eeb55a3e702893d113 (patch) | |
tree | 3772c1e940edcc8127f5ac8c8ad40288845a037e /src/compiler/scala/tools/nsc/typechecker/Implicits.scala | |
parent | 38c3ca67563a68e8f30fd84282b1b9c4cebadeaa (diff) | |
download | scala-d4c63b2af19fb48730b3c3eeb55a3e702893d113.tar.gz scala-d4c63b2af19fb48730b3c3eeb55a3e702893d113.tar.bz2 scala-d4c63b2af19fb48730b3c3eeb55a3e702893d113.zip |
Fixed #2494, plus some reorganization of swing ...
Fixed #2494, plus some reorganization of swing imports
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index a32f945553..1e07442eee 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -100,6 +100,21 @@ self: Analyzer => tpeCache } + /** Does type `tp` contain an Error type as parameter or result? + */ + private def containsError(tp: Type): Boolean = tp match { + case PolyType(tparams, restpe) => containsError(restpe) + case MethodType(params, restpe) => (params map (_.tpe) exists (_.isError)) || containsError(restpe) + case _ => tp.isError + } + + def isCyclicOrErroneous = try { + containsError(tpe) + } catch { + case ex: CyclicReference => + true + } + override def equals(other: Any) = other match { case that: ImplicitInfo => this.name == that.name && @@ -218,14 +233,6 @@ self: Analyzer => case _ => tp } - /** Does type `tp` contain an Error type as parameter or result? - */ - private def containsError(tp: Type): Boolean = tp match { - case PolyType(tparams, restpe) => containsError(restpe) - case MethodType(params, restpe) => (params map (_.tpe) exists (_.isError)) || containsError(restpe) - case _ => tp.isError - } - /** Does type `dtor` dominate type `dted`? * This is the case if the stripped cores `dtor1` and `dted1` of both types are * the same wrt `=:=`, or if they overlap and the complexity of `dtor1` is higher @@ -508,7 +515,7 @@ self: Analyzer => * SearchFailure if not. */ def tryImplicit(info: ImplicitInfo): SearchResult = - if (containsError(info.tpe) || + if (info.isCyclicOrErroneous || (isLocal && shadowed.contains(info.name)) || (isView && (info.sym == Predef_identity || info.sym == Predef_conforms)) //@M this condition prevents no-op conversions, which are a problem (besides efficiency), // TODO: remove `info.sym == Predef_identity` once we have a new STARR that only has conforms as an implicit |