Skip to content

Scala 3 Metaprogramming Reference has some invalid example code #2290

Open
@coreywoodfield

Description

@coreywoodfield

The example here is as follows:

def collectPatternVariables(tree: Tree)(using ctx: Context): List[Symbol] =
  val acc = new TreeAccumulator[List[Symbol]]:
    def foldTree(syms: List[Symbol], tree: Tree)(owner: Symbol): List[Symbol] = tree match
      case ValDef(_, _, rhs) =>
        val newSyms = tree.symbol :: syms
        foldTree(newSyms, body)(tree.symbol)
      case _ =>
        foldOverTree(syms, tree)(owner)
  acc(Nil, tree)

Where does body come from? I'm guessing the pattern should maybe be ValDef(_, body, rhs) but I'm not 100% sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    scala-3scala 3 documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions