@@ -411,14 +411,14 @@ object Implicits:
411411
412412 /** A failed search */
413413 case class SearchFailure (tree : Tree ) extends SearchResult {
414- final def isAmbiguous : Boolean = tree.tpe.isInstanceOf [AmbiguousImplicits ]
414+ final def isAmbiguous : Boolean = tree.tpe.isInstanceOf [AmbiguousImplicits | TooUnspecific ]
415415 final def reason : SearchFailureType = tree.tpe.asInstanceOf [SearchFailureType ]
416416 }
417417
418418 object SearchFailure {
419419 def apply (tpe : SearchFailureType , span : Span )(using Context ): SearchFailure = {
420420 val id = tpe match
421- case tpe : AmbiguousImplicits =>
421+ case tpe : ( AmbiguousImplicits | TooUnspecific ) =>
422422 untpd.SearchFailureIdent (nme.AMBIGUOUS , s " /* ambiguous: ${tpe.explanation} */ " )
423423 case _ =>
424424 untpd.SearchFailureIdent (nme.MISSING , " /* missing */" )
@@ -504,11 +504,14 @@ object Implicits:
504504 SearchFailure (ImplicitSearchTooLarge , NoSpan )(using NoContext )
505505
506506 /** A failure value indicating that an implicit search for a conversion was not tried */
507- class TooUnspecific (target : Type ) extends NoMatchingImplicits (NoType , EmptyTree , OrderingConstraint .empty):
507+ case class TooUnspecific (target : Type ) extends NoMatchingImplicits (NoType , EmptyTree , OrderingConstraint .empty):
508508 override def whyNoConversion (using Context ): String =
509509 i """
510510 |Note that implicit conversions were not tried because the result of an implicit conversion
511511 |must be more specific than $target"""
512+ override def explanation (using Context ) =
513+ i """ ${super .explanation}.
514+ |The expected type $target is not specific enough, so no search was attempted """
512515 override def toString = s " TooUnspecific "
513516
514517 /** An ambiguous implicits failure */
@@ -1484,7 +1487,7 @@ trait Implicits:
14841487
14851488 private def searchImplicit (contextual : Boolean ): SearchResult =
14861489 if isUnderspecified(wildProto) then
1487- NoMatchingImplicitsFailure
1490+ SearchFailure ( TooUnspecific (pt), span)
14881491 else
14891492 val eligible =
14901493 if contextual then
0 commit comments