Skip to content

DefDef/Lambda takes continuation which assumes Tree, not Term #23038

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

Open
j-mie6 opened this issue Apr 23, 2025 · 1 comment
Open

DefDef/Lambda takes continuation which assumes Tree, not Term #23038

j-mie6 opened this issue Apr 23, 2025 · 1 comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:question

Comments

@j-mie6
Copy link

j-mie6 commented Apr 23, 2025

The API for both DefDef and Lambda in scala.quoted take a function of the form List[List[Tree]] => Option[Term] and List[Tree] => Term, respectively. The Trees here are the parameters of the new function for use in the body. As such, I'm reasonably sure these are always just Terms (since they will be identifiers representing the parameters). This results in any use of DefDef.apply or Lambda.apply having to first cast these Trees into the more useful Term by either asInstanceOf or .asExpr.asTerm, which is not pleasant (especially as it gives the aura of unsafety in the macro code).

If I'm not overlooking something here, it would be good to switch these to use Term. Thankfully, these are (erased) parameters to the => type, which means this change would be binary-compatible, and via contravariance, existing code passing a ...[Tree] => ... function will continue to type check.

@j-mie6 j-mie6 added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 23, 2025
@Gedochao Gedochao added itype:question area:metaprogramming:quotes Issues related to quotes and splices and removed itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 24, 2025
@Gedochao
Copy link
Contributor

@jchyb thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:question
Projects
None yet
Development

No branches or pull requests

2 participants