Skip to content

Commit b5755de

Browse files
committed
Use finalResultType
1 parent 859d30b commit b5755de

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2748,7 +2748,7 @@ class MissingImplicitArgument(
27482748
i"\n- ${imp.symbol.showDcl}${convs.map(c => "\n - " + c.symbol.showDcl).mkString}"
27492749
def noChainConversionsNote(ignoredConversions: Iterable[(TermRef, Iterable[TermRef])]): Option[String] = {
27502750
val convsFormatted = ignoredConversions.map{ (imp, convs) =>
2751-
i"\n- ${imp.symbol.showDcl}${convs.map(c => "\n - " + c.symbol.showDcl).mkString}"
2751+
s"\n- ${imp.symbol.showDcl}${convs.map(c => "\n - " + c.symbol.showDcl).mkString}"
27522752
}.mkString
27532753
Option.when(ignoredConversions.nonEmpty)(
27542754
i"\n\nNote: implicit conversions are not automatically applied to arguments of using clauses. " +

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -935,8 +935,17 @@ trait Implicits:
935935
allImplicits(ctx.implicits).map { imp =>
936936
// todo imp.underlyingRef.underlying does not work for implicit functions or givens
937937
// with type or implicit parameters
938-
val convs = ctx.implicits.eligible(ViewProto(imp.underlyingRef.underlying, wildApprox(fail.expectedType)))
939-
(imp.underlyingRef, convs.map(_.ref))
938+
val impRef = imp.underlyingRef
939+
val impResultType = wildApprox(impRef.underlying.finalResultType)
940+
val convs = ctx.implicits.eligible(ViewProto(impResultType, fail.expectedType))
941+
.filter { conv =>
942+
if !conv.isConversion then false
943+
else
944+
// Actually feed the summoned implicit into the Conversion to
945+
// check if it works
946+
true
947+
}
948+
(impRef, convs.map(_.ref))
940949
}.filter(_._2.nonEmpty)
941950
else
942951
Nil

0 commit comments

Comments
 (0)