-
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 a check for correct Array shape in quotes.reflect.ClassOfConstant
- Loading branch information
Showing
4 changed files
with
36 additions
and
1 deletion.
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,15 @@ | ||
|
||
-- Error: tests/neg-macros/i21916/Test_2.scala:1:33 -------------------------------------------------------------------- | ||
1 |@main def Test: Unit = Macro.test() // error | ||
| ^^^^^^^^^^^^ | ||
| Exception occurred while executing macro expansion. | ||
| java.lang.AssertionError: Illegal empty Array type constructor. Please supply a type parameter. | ||
| at Macro$.testImpl(Macro_1.scala:8) | ||
| | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
|Inline stack trace | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
|This location contains code that was inlined from Macro_1.scala:3 | ||
3 | inline def test() = ${testImpl} | ||
| ^^^^^^^^^^^ | ||
--------------------------------------------------------------------------------------------------------------------- |
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,9 @@ | ||
import scala.quoted._ | ||
object Macro: | ||
inline def test() = ${testImpl} | ||
def testImpl(using Quotes): Expr[Any] = { | ||
import quotes.reflect._ | ||
val tpe = TypeRepr.of[Array[Byte]] match | ||
case AppliedType(tycons, _) => tycons | ||
Literal(ClassOfConstant(tpe)).asExpr | ||
} |
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 @@ | ||
@main def Test: Unit = Macro.test() // error |