-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Error instead of StaleSymbol crash for certain cyclic macro…
… dependencies" to LTS (#20867) Backports #19549 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
9 changed files
with
68 additions
and
3 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
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,4 @@ | ||
-- Error: tests/neg/i19351/A.scala:3:35 -------------------------------------------------------------------------------- | ||
3 | inline def myMacro(): x.type = ${myMacroExpr} // error | ||
| ^ | ||
|Cyclic macro dependency; macro refers to a toplevel symbol in tests/neg/i19351/A.scala from which the macro is called |
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,5 @@ | ||
//object A: | ||
val x: Int = 1 | ||
inline def myMacro(): x.type = ${myMacroExpr} // error | ||
def test = myMacro() | ||
|
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,3 @@ | ||
import scala.quoted.* | ||
//import A.* | ||
def myMacroExpr(using Quotes): Expr[x.type] = '{???} |
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,12 @@ | ||
-- Error: tests/neg/i19351a/Test.scala:8:34 ---------------------------------------------------------------------------- | ||
8 |inline def not(b: Bool): Bool = ${notMacro('b)} // error // error | ||
| ^ | ||
|Cyclic macro dependency; macro refers to a toplevel symbol in tests/neg/i19351a/Test.scala from which the macro is called | ||
-- [E046] Cyclic Error: tests/neg/i19351a/Test.scala:8:46 -------------------------------------------------------------- | ||
8 |inline def not(b: Bool): Bool = ${notMacro('b)} // error // error | ||
| ^ | ||
| Cyclic reference involving method $anonfun | ||
| | ||
| Run with -explain-cyclic for more details. | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,13 @@ | ||
// Macro class | ||
package test | ||
|
||
import scala.quoted.* | ||
|
||
def notMacro(bool: Expr[Bool])(using Quotes): Expr[Bool] = | ||
'{$bool(False, True)} | ||
|
||
def showMacro(bool: Expr[Bool])(using Quotes): Expr[String] = | ||
'{$bool("TRUE", "FALSE")} | ||
|
||
def foldMacro[T: Type](bool: Expr[Bool], t: Expr[T], f: Expr[T])(using Quotes): Expr[T] = | ||
'{$bool($t, $f)} |
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,15 @@ | ||
//Test class | ||
package test | ||
|
||
type Bool = [R] => (R, R) => R | ||
val True: Bool = [R] => (t: R, _: R) => t | ||
val False: Bool = [R] => (_: R, f: R) => f | ||
|
||
inline def not(b: Bool): Bool = ${notMacro('b)} // error // error | ||
inline def show(b: Bool): String = ${showMacro('b)} | ||
//inline def not(b: Bool): Bool = ${foldMacro('b, 'False, 'True)} | ||
//inline def show(b: Bool): String = ${foldMacro('b, '{"TRUE"}, '{"FALSE"})} | ||
|
||
|
||
@main def testing = | ||
println(show(not(True))) |