@@ -369,13 +369,16 @@ object Implicits {
369
369
/** A "massaging" function for displayed types to give better info in error diagnostics */
370
370
def clarify (tp : Type )(implicit ctx : Context ): Type = tp
371
371
372
- final protected def qualify (implicit ctx : Context ): String =
373
- if (expectedType.exists)
374
- if (argument.isEmpty) em " match type ${clarify(expectedType)}"
375
- else em " convert from ${argument.tpe} to ${clarify(expectedType)}"
376
- else
372
+ final protected def qualify (implicit ctx : Context ): String = expectedType match {
373
+ case SelectionProto (name, mproto, _, _) if ! argument.isEmpty =>
374
+ em " provide an extension method ` $name` on ${argument.tpe}"
375
+ case NoType =>
377
376
if (argument.isEmpty) em " match expected type "
378
377
else em " convert from ${argument.tpe} to expected type "
378
+ case _ =>
379
+ if (argument.isEmpty) em " match type ${clarify(expectedType)}"
380
+ else em " convert from ${argument.tpe} to ${clarify(expectedType)}"
381
+ }
379
382
380
383
/** An explanation of the cause of the failure as a string */
381
384
def explanation (implicit ctx : Context ): String
@@ -425,9 +428,12 @@ object Implicits {
425
428
class AmbiguousImplicits (val alt1 : SearchSuccess , val alt2 : SearchSuccess , val expectedType : Type , val argument : Tree ) extends SearchFailureType {
426
429
def explanation (implicit ctx : Context ): String =
427
430
em " both ${err.refStr(alt1.ref)} and ${err.refStr(alt2.ref)} $qualify"
428
- override def whyNoConversion (implicit ctx : Context ): String =
429
- " \n Note that implicit conversions cannot be applied because they are ambiguous;" +
430
- " \n " + explanation
431
+ override def whyNoConversion (implicit ctx : Context ): String = {
432
+ val what = if (expectedType.isInstanceOf [SelectionProto ]) " extension methods" else " conversions"
433
+ i """
434
+ |Note that implicit $what cannot be applied because they are ambiguous;
435
+ | $explanation"""
436
+ }
431
437
}
432
438
433
439
class MismatchedImplicit (ref : TermRef ,
0 commit comments