summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cunei <antonio.cunei@epfl.ch>2010-09-14 12:41:40 +0000
committerAntonio Cunei <antonio.cunei@epfl.ch>2010-09-14 12:41:40 +0000
commit3ef8c7575deb5081bf623dde9d29c44648ce59af (patch)
treed3cbb5f39dc284916994df5bdaf7184489489bfb
parentceb38470116de2d7a2bdeb1f3aaacba8bf09bf60 (diff)
downloadscala-3ef8c7575deb5081bf623dde9d29c44648ce59af.tar.gz
scala-3ef8c7575deb5081bf623dde9d29c44648ce59af.tar.bz2
scala-3ef8c7575deb5081bf623dde9d29c44648ce59af.zip
Merged revisions 22977 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r22977 | moors | 2010-09-14 14:11:54 +0200 (Tue, 14 Sep 2010) | 5 lines relax implicit divergence check patch contributed by Mark Harrah in http://article.gmane.org/gmane.comp.lang.scala/20700 reviewed by moors and odersky ........
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala4
-rw-r--r--test/files/neg/t0226.check3
-rw-r--r--test/files/pos/relax_implicit_divergence.scala7
4 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 42c1329edf..28c4b67db9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -102,7 +102,7 @@ trait Contexts { self: Analyzer =>
// not inherited to child contexts
var depth: Int = 0
var imports: List[ImportInfo] = List() // currently visible imports
- var openImplicits: List[Type] = List() // types for which implicit arguments
+ var openImplicits: List[(Type,Symbol)] = List() // types for which implicit arguments
// are currently searched
// for a named application block (Tree) the corresponding NamedApplyInfo
var namedApplyBlockInfo: Option[(Tree, NamedApplyInfo)] = None
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 63b971d2fd..adcae7d9b1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -344,14 +344,14 @@ self: Analyzer =>
* @pre <code>info.tpe</code> does not contain an error
*/
private def typedImplicit(info: ImplicitInfo): SearchResult =
- context.openImplicits find (dominates(pt, _)) match {
+ (context.openImplicits find { case (tp, sym) => sym == tree.symbol && dominates(pt, tp)}) match {
case Some(pending) =>
// println("Pending implicit "+pending+" dominates "+pt+"/"+undetParams) //@MDEBUG
throw DivergentImplicit
SearchFailure
case None =>
try {
- context.openImplicits = pt :: context.openImplicits
+ context.openImplicits = (pt, tree.symbol) :: context.openImplicits
// println(" "*context.openImplicits.length+"typed implicit "+info+" for "+pt) //@MDEBUG
typedImplicit0(info)
} catch {
diff --git a/test/files/neg/t0226.check b/test/files/neg/t0226.check
index e27ffbc1e1..af81e41a6a 100644
--- a/test/files/neg/t0226.check
+++ b/test/files/neg/t0226.check
@@ -4,8 +4,7 @@ t0226.scala:5: error: not found: type A1
t0226.scala:5: error: not found: type A1
(implicit _1: Foo[List[A1]], _2: Foo[A2]): Foo[Tuple2[List[A1], A2]] =
^
-t0226.scala:8: error: diverging implicit expansion for type Test.this.Foo[((List[Char], Int), (object Nil, Int))]
-starting with method list2Foo in class Test
+t0226.scala:8: error: could not find implicit value for parameter rep: Test.this.Foo[((List[Char], Int), (object Nil, Int))]
foo(((List('b'), 3), (Nil, 4)))
^
three errors found
diff --git a/test/files/pos/relax_implicit_divergence.scala b/test/files/pos/relax_implicit_divergence.scala
new file mode 100644
index 0000000000..8525c84bab
--- /dev/null
+++ b/test/files/pos/relax_implicit_divergence.scala
@@ -0,0 +1,7 @@
+class A(val options: Seq[String])
+
+object Test {
+ implicit def ss: Equiv[Seq[String]] = error("dummy")
+ implicit def equivA(implicit seqEq: Equiv[Seq[String]]): Equiv[A] = error("dummy")
+ implicitly[Equiv[A]]
+} \ No newline at end of file