-
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.
Add missing error messages to asserts in QuotesImpl
- Loading branch information
1 parent
dd37f07
commit 39d45dc
Showing
7 changed files
with
70 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
-- Error: tests/neg/i20946/Test_2.scala:5:29 --------------------------------------------------------------------------- | ||
5 | macroWithAssertFailing[Int](123) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Exception occurred while executing macro expansion. | ||
| java.lang.AssertionError: assertion failed: expected a term symbol but received class Int | ||
| at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8) | ||
| at scala.quoted.runtime.impl.QuotesImpl$reflect$Ref$.apply(QuotesImpl.scala:475) | ||
| at scala.quoted.runtime.impl.QuotesImpl$reflect$Ref$.apply(QuotesImpl.scala:474) | ||
| at Macro_1$package$.macroWithAssertFailingImpl(Macro_1.scala:6) | ||
| | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from Test_2.scala:1 | ||
1 |inline def macroWithAssertFailing[T](t: T): Unit = ${ macroWithAssertFailingImpl[T]('t) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
--------------------------------------------------------------------------------------------------------------------- |
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.* | ||
|
||
def macroWithAssertFailingImpl[T: Type](t: Expr[T])(using Quotes): Expr[Unit] = { | ||
import quotes.reflect.* | ||
|
||
Ref(TypeRepr.of[T].typeSymbol) | ||
|
||
'{()} | ||
} | ||
|
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 @@ | ||
inline def macroWithAssertFailing[T](t: T): Unit = ${ macroWithAssertFailingImpl[T]('t) } | ||
|
||
@main | ||
def run = | ||
macroWithAssertFailing[Int](123) // 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,18 @@ | ||
|
||
-- Error: tests/neg/i20946a/Test_2.scala:5:29 -------------------------------------------------------------------------- | ||
5 | macroWithAssertFailing[Int](123) // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| Exception occurred while executing macro expansion. | ||
| java.lang.AssertionError: assertion failed: Expected a type symbol, but got val <none> | ||
| at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8) | ||
| at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeIdent$.apply(QuotesImpl.scala:1165) | ||
| at scala.quoted.runtime.impl.QuotesImpl$reflect$TypeIdent$.apply(QuotesImpl.scala:1164) | ||
| at Macro_1$package$.macroWithAssertFailingImpl(Macro_1.scala:6) | ||
| | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from Test_2.scala:1 | ||
1 |inline def macroWithAssertFailing[T](t: T): Unit = ${ macroWithAssertFailingImpl[T]('t) } | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
--------------------------------------------------------------------------------------------------------------------- |
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.* | ||
|
||
def macroWithAssertFailingImpl[T: Type](t: Expr[T])(using Quotes): Expr[Unit] = { | ||
import quotes.reflect.* | ||
|
||
TypeIdent(t.asTerm.symbol) | ||
|
||
'{()} | ||
} | ||
|
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 @@ | ||
inline def macroWithAssertFailing[T](t: T): Unit = ${ macroWithAssertFailingImpl[T]('t) } | ||
|
||
@main | ||
def run = | ||
macroWithAssertFailing[Int](123) // error | ||
|