Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve implicit parameter error message with aliases #17125

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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