Skip to content

Fix #9014: On implicit search failure print original inline call #9222

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

Merged
merged 1 commit into from
Jun 22, 2020
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
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -786,10 +786,14 @@ trait Implicits { self: Typer =>
case _ =>
arg.tpe match {
case tpe: SearchFailureType =>
val original = arg match
case Inlined(call, _, _) => call
case _ => arg

i"""$headline.
|I found:
|
| ${arg.show.replace("\n", "\n ")}
| ${original.show.replace("\n", "\n ")}
|
|But ${tpe.explanation}."""
}
Expand Down
10 changes: 10 additions & 0 deletions tests/neg-macros/i9014.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

-- Error: tests/neg-macros/i9014/Test_2.scala:1:23 ---------------------------------------------------------------------
1 |val tests = summon[Bar] // error
| ^
| no implicit argument of type Bar was found for parameter x of method summon in object DottyPredef.
| I found:
|
| given_Bar
|
| But method given_Bar does not match type Bar.
4 changes: 4 additions & 0 deletions tests/neg-macros/i9014/Macros_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import scala.quoted._
trait Bar
inline given as Bar = ${ impl }
def impl(using qctx: QuoteContext): Expr[Bar] = qctx.throwError("Failed to expand!")
1 change: 1 addition & 0 deletions tests/neg-macros/i9014/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
val tests = summon[Bar] // error
9 changes: 9 additions & 0 deletions tests/neg/i9014.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- Error: tests/neg/i9014.scala:4:25 -----------------------------------------------------------------------------------
4 | val tests = summon[Bar] // error
| ^
| no implicit argument of type Bar was found for parameter x of method summon in object DottyPredef.
| I found:
|
| Bar.given_Bar
|
| But method given_Bar in object Bar does not match type Bar.
4 changes: 4 additions & 0 deletions tests/neg/i9014.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
trait Bar
object Bar:
inline given as Bar = compiletime.error("Failed to expand!")
val tests = summon[Bar] // error