Skip to content

Commit 9c1d942

Browse files
committed
New test exercising implicit function types
1 parent 0e8a74d commit 9c1d942

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,18 @@ trait Implicits { self: Typer =>
673673
}
674674
}
675675

676+
/** A string indicating the formal parameter corresponding to a missing argument */
677+
def implicitParamString(paramName: TermName, methodStr: String, tree: Tree)(implicit ctx: Context): String =
678+
tree match {
679+
case Select(qual, nme.apply) if defn.isFunctionType(qual.tpe.widen) =>
680+
val qt = qual.tpe.widen
681+
val qt1 = qt.dealias
682+
def addendum = if (qt1 eq qt) "" else (i"\nwhich is an alias of: $qt1")
683+
em"parameter of ${qual.tpe.widen}$addendum"
684+
case _ =>
685+
em"parameter ${paramName} of $methodStr"
686+
}
687+
676688
private def assumedCanEqual(ltp: Type, rtp: Type)(implicit ctx: Context) = {
677689
def eqNullable: Boolean = {
678690
val other =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
20432043
arg.tpe match {
20442044
case failure: SearchFailureType =>
20452045
ctx.error(
2046-
missingArgMsg(arg, formal, em"parameter ${paramName} of $methodStr"),
2046+
missingArgMsg(arg, formal, implicitParamString(paramName, methodStr, tree)),
20472047
tree.pos.endPos)
20482048
case _ =>
20492049
}

0 commit comments

Comments
 (0)