Closed
Description
minimized code
Macro file:
package playground
import scala.quoted._, scala.quoted.matching._
import delegate scala.quoted._
import scala.tasty._
object macros {
inline def mcr(x: => Any) = ${mcrImpl('x)}
def mcrImpl(body: Expr[Any]) given (ctx: QuoteContext): Expr[Any] = {
import ctx.tasty._
body.unseal match { case Block(_, _) => '{2} }
}
}
Main method file:
package playground
import playground.macros._
object Main {
def main(args: Array[String]): Unit = mcr { 2 }
}
On execution, it says:
[error] -- Error: /Users/anatolii/Projects/dotty/playground/core/src/main/scala/playground/Main.scala:6:44
[error] 6 | def main(args: Array[String]): Unit = mcr { 2 }
[error] | ^^^^^^^^^
[error] |An exception occurred while executing macro expansion: Inlined(EmptyTree,List(),Literal(Constant(2))) (of class dotty.tools.dotc.ast.Trees$Inlined)
[error] |sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[error] |sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[error] |sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[error] |java.lang.reflect.Method.invoke(Method.java:498)
[error] |
[error] | This location is in code that was inlined at Main.scala:6
[error] one error found
expectation
The type of the exception, as well as its error message, should be output instead of the "An exception occurred".