Skip to content

Commit

Permalink
Improve implicit parameter error message with aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Mar 17, 2023
1 parent 2dec682 commit b223c20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ trait Implicits:
case Select(qual, nme.apply) if defn.isFunctionType(qual.tpe.widen) =>
val qt = qual.tpe.widen
val qt1 = qt.dealiasKeepAnnots
def addendum = if (qt1 eq qt) "" else (i"\nThe required type is an alias of: $qt1")
def addendum = if (qt1 eq qt) "" else (i"\nWhere $qt is an alias of: $qt1")
i"parameter of ${qual.tpe.widen}$addendum"
case _ =>
i"${ if paramName.is(EvidenceParamName) then "an implicit parameter"
Expand Down
5 changes: 5 additions & 0 deletions tests/neg/i17122.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- [E172] Type Error: tests/neg/i17122.scala:7:14 ----------------------------------------------------------------------
7 |def test = m() // error
| ^
| No given instance of type A was found for parameter of C
| Where C is an alias of: (A) ?=> B
7 changes: 7 additions & 0 deletions tests/neg/i17122.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
case class A()
case class B()

type C = A ?=> B
def m(): C = ???

def test = m() // error

0 comments on commit b223c20

Please sign in to comment.