-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suspend macros when class not found during macro expansion
- Loading branch information
1 parent
4de288b
commit 1f529ef
Showing
6 changed files
with
49 additions
and
23 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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
-- Error: tests/neg-macros/macros-in-same-project-4/Bar.scala:5:13 ----------------------------------------------------- | ||
5 | Foo.myMacro() // error | ||
| ^^^^^^^^^^^^^ | ||
|Failed to expand macro. This macro depends on an implementation that is defined in the same project and not yet compiled. | ||
|In particular method myMacro depends on method aMacroImplementation. | ||
| | ||
|Moving method aMacroImplementation to a different project would fix this. | ||
| This location is in code that was inlined at Bar.scala:5 | ||
Cyclic macro dependencies in tests/neg-macros/macros-in-same-project-4/Bar.scala. | ||
Compilation stopped since no further progress can be made. | ||
|
||
To fix this, place macros in one set of files and their callers in another. | ||
|
||
Compiling with -Xprint-suspension gives more information. |
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
// nopos-error | ||
import scala.quoted._ | ||
|
||
object Bar { | ||
|
||
Foo.myMacro() // error | ||
Foo.myMacro() | ||
|
||
def hello()(given QuoteContext): Expr[Unit] = '{ println("Hello") } | ||
} |
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,10 @@ | ||
import scala.quoted._ | ||
|
||
object Bar { | ||
|
||
Foo.myMacro() // error | ||
|
||
def aMacroImplementation(given QuoteContext): Expr[Unit] = Bar.hello() | ||
|
||
def hello()(given QuoteContext): Expr[Unit] = '{ println("Hello") } | ||
} |
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,8 @@ | ||
import scala.quoted._ | ||
import Bar.aMacroImplementation | ||
|
||
object Foo { | ||
|
||
inline def myMacro(): Unit = ${ aMacroImplementation } | ||
|
||
} |