Skip to content

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

Open
@j-mie6

Description

@j-mie6

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions