forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate implicit search errors from implicit macros
Fixes partially scala#16835
- Loading branch information
1 parent
a356581
commit 1f5a990
Showing
5 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
-- Error: tests/neg-macros/i16835/Test_2.scala:1:17 -------------------------------------------------------------------- | ||
1 |def test: Unit = foo // error | ||
| ^^^ | ||
| my error | ||
| my second error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import scala.quoted.* | ||
|
||
class Bar | ||
|
||
inline def foo: Unit = ${ fooExpr } | ||
|
||
def fooExpr(using Quotes): Expr[Unit] = | ||
import quotes.reflect.* | ||
Implicits.search(TypeRepr.of[Bar]) match | ||
case res: ImplicitSearchSuccess => '{} | ||
case failure: ImplicitSearchFailure => | ||
report.errorAndAbort(failure.explanation) | ||
|
||
|
||
inline given bar: Bar = ${ barExpr } | ||
|
||
def barExpr(using Quotes): Expr[Bar] = | ||
import quotes.reflect.* | ||
report.error(s"my error") | ||
report.error(s"my second error") | ||
'{ new Bar } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
def test: Unit = foo // error |