diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-17 10:51:33 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-17 13:54:11 -0700 |
commit | dd33e280e2520cfc155c90db01c48df8188d0433 (patch) | |
tree | c32444378a84dae8762a3928c26cc55a0cb06ac0 | |
parent | e927cbc39a081dc0eeddc1bc264bcbe3f9b3c7d0 (diff) | |
download | scala-dd33e280e2520cfc155c90db01c48df8188d0433.tar.gz scala-dd33e280e2520cfc155c90db01c48df8188d0433.tar.bz2 scala-dd33e280e2520cfc155c90db01c48df8188d0433.zip |
SI-7486 regression in implicit resolution.
What a touchy beast the compiler is.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 10 | ||||
-rw-r--r-- | test/files/pos/t7486.scala | 8 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 770aef5d61..ef87a32c1d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -996,11 +996,15 @@ trait Implicits { if (divergence || DivergentImplicitRecovery.sym != null) { if (settings.Xdivergence211.value) DivergingImplicitExpansionError(tree, pt, DivergentImplicitRecovery.sym)(context) else throw DivergentImplicit - } else invalidImplicits take 1 foreach { sym => - def isSensibleAddendum = pt match { + } + else if (invalidImplicits.nonEmpty) { + val sym = invalidImplicits.head + // We don't even dare look if errors are being buffered + // !sym.hasFlag(LOCKED) is a hail mary between SI-2206 and SI-7486 + def isSensibleAddendum = !sym.hasFlag(LOCKED) && (pt match { case Function1(_, out) => out <:< sym.tpe.finalResultType case _ => pt <:< sym.tpe.finalResultType - } + }) // Don't pitch in with this theory unless it looks plausible that the // implicit would have helped setAddendum(pos, () => diff --git a/test/files/pos/t7486.scala b/test/files/pos/t7486.scala new file mode 100644 index 0000000000..6dd7f4c4ac --- /dev/null +++ b/test/files/pos/t7486.scala @@ -0,0 +1,8 @@ +object Test{ + var locker = 0 + // remove implicit, or change to `locker = locker + 1` to make it compile. + implicit val davyJones0 = { + locker += 0 + 0 + } +} |