summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2013-05-10 10:09:42 -0700
committerPaul Phillips <paulp@improving.org>2013-05-10 10:09:42 -0700
commitfb99a1ed30b5cb1f050d67c22beffb7f8b68d701 (patch)
tree06ca71b5f46889b17fa1ce0f9c75ac0128709281 /src/compiler
parent5c77e01794434b2fa01a1bd250c08198c31796e3 (diff)
parente86832d7e845014dd272b71e2c12f0eedd55e85a (diff)
downloadscala-fb99a1ed30b5cb1f050d67c22beffb7f8b68d701.tar.gz
scala-fb99a1ed30b5cb1f050d67c22beffb7f8b68d701.tar.bz2
scala-fb99a1ed30b5cb1f050d67c22beffb7f8b68d701.zip
Merge pull request #2488 from paulp/issue/7441
SI-7441 Don't ramble on about inapplicable implicits.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 01ae0a7a94..04e0b9d653 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -149,7 +149,7 @@ trait Implicits {
class SearchResult(val tree: Tree, val subst: TreeTypeSubstituter) {
override def toString = "SearchResult(%s, %s)".format(tree,
if (subst.isEmpty) "" else subst)
-
+
def isFailure = false
def isAmbiguousFailure = false
final def isSuccess = !isFailure
@@ -158,7 +158,7 @@ trait Implicits {
lazy val SearchFailure = new SearchResult(EmptyTree, EmptyTreeTypeSubstituter) {
override def isFailure = true
}
-
+
lazy val AmbiguousSearchFailure = new SearchResult(EmptyTree, EmptyTreeTypeSubstituter) {
override def isFailure = true
override def isAmbiguousFailure = true
@@ -892,11 +892,20 @@ trait Implicits {
*/
if (divergence)
throw DivergentImplicit
-
- if (invalidImplicits.nonEmpty)
+ else invalidImplicits take 1 foreach { sym =>
+ def isSensibleAddendum = pt match {
+ case Function1(_, out) => out <:< sym.tpe.finalResultType
+ case tp => tp <:< sym.tpe.finalResultType
+ case _ => false
+ }
+ // Don't pitch in with this theory unless it looks plausible that the
+ // implicit would have helped
setAddendum(pos, () =>
- "\n Note: implicit "+invalidImplicits.head+" is not applicable here"+
- " because it comes after the application point and it lacks an explicit result type")
+ if (isSensibleAddendum)
+ s"\n Note: implicit $sym is not applicable here because it comes after the application point and it lacks an explicit result type"
+ else ""
+ )
+ }
}
best