-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symbol.asQuotes
not working for quote that creates a context function
#16963
Comments
Not that the code used |
You are right, in general you should not rely on Further observation: Adding yet another Side note: The code compiles in Scala 3.2.2. |
Minimizedimport scala.quoted.*
inline def myMacro = ${ myMacroExpr }
def myMacroExpr(using Quotes) =
import quotes.reflect.*
'{ def innerMethod = (_: String) ?=> ???; () }.asTerm match
case block @ Inlined(_, _, Block(List(defdef: DefDef), _)) =>
val rhs =
given Quotes = defdef.symbol.asQuotes
'{ (x: String) ?=> ??? }.asTerm
Block(List(DefDef(defdef.symbol, _ => Some(rhs))), '{}.asTerm).asExprOf[Unit] def method: Unit = myMacro |
Fixes #16963 The regression here was caused by 229fdaa, by the changes to TreeInfo. Since the aim of that PR was to reduce unnecessary `Inlined` removal, instead of reintroducing `Inlined` node removal in `closureDef` in `TreeInfo` (which is used in many places in the compiler), we just remove it directly in erasure, where it would have been removed later in the same manner either way (in `typedInlined`).
Compiler version
3.3.1-RC1-bin-20230216-2507577-NIGHTLY
Minimized code
Consider the following macro definition, which replaces the context function body of a
def
with another context function:Macro call site:
Output
The compiler crashes.
Compiler Error and Stack Trace
The text was updated successfully, but these errors were encountered: