Skip to content

Commit a3543f2

Browse files
authored
Merge pull request #9222 from dotty-staging/fix-#9014
Fix #9014: On implicit search failure print original inline call
2 parents f000afe + 45edfb0 commit a3543f2

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,10 +786,14 @@ trait Implicits { self: Typer =>
786786
case _ =>
787787
arg.tpe match {
788788
case tpe: SearchFailureType =>
789+
val original = arg match
790+
case Inlined(call, _, _) => call
791+
case _ => arg
792+
789793
i"""$headline.
790794
|I found:
791795
|
792-
| ${arg.show.replace("\n", "\n ")}
796+
| ${original.show.replace("\n", "\n ")}
793797
|
794798
|But ${tpe.explanation}."""
795799
}

tests/neg-macros/i9014.check

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
-- Error: tests/neg-macros/i9014/Test_2.scala:1:23 ---------------------------------------------------------------------
3+
1 |val tests = summon[Bar] // error
4+
| ^
5+
| no implicit argument of type Bar was found for parameter x of method summon in object DottyPredef.
6+
| I found:
7+
|
8+
| given_Bar
9+
|
10+
| But method given_Bar does not match type Bar.

tests/neg-macros/i9014/Macros_1.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import scala.quoted._
2+
trait Bar
3+
inline given as Bar = ${ impl }
4+
def impl(using qctx: QuoteContext): Expr[Bar] = qctx.throwError("Failed to expand!")

tests/neg-macros/i9014/Test_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
val tests = summon[Bar] // error

tests/neg/i9014.check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Error: tests/neg/i9014.scala:4:25 -----------------------------------------------------------------------------------
2+
4 | val tests = summon[Bar] // error
3+
| ^
4+
| no implicit argument of type Bar was found for parameter x of method summon in object DottyPredef.
5+
| I found:
6+
|
7+
| Bar.given_Bar
8+
|
9+
| But method given_Bar in object Bar does not match type Bar.

tests/neg/i9014.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
trait Bar
2+
object Bar:
3+
inline given as Bar = compiletime.error("Failed to expand!")
4+
val tests = summon[Bar] // error

0 commit comments

Comments
 (0)