Closed
Description
Minimized code
val expr = '{ trait A; new A {} } // This code expression will produce Template expression
new TreeMap {}.transformTree(expr.asTerm)(Symbol.spliceOwner) // This code should traverse all child nodes of Template
Expectation
- scala.quoted.reflect should have Template type definition
- TreeMap traverses the child nodes of Template node
Scala 3 macro should support traversing nodes inside Template node (https://github.com/lampepfl/dotty/blob/M3/compiler/src/dotty/tools/dotc/ast/Trees.scala#L784-L794), which will be generated by the code like above. Currently, TreeMap.transformTree https://github.com/lampepfl/dotty/blob/M3/library/src/scala/quoted/Quotes.scala#L3989-L3991 has no such pattern so we cannot rewrite a tree if it contains Template node.
QuotesImpl in Scala 3.0.0-M3 also has no corresponding definition for Template node: https://github.com/lampepfl/dotty/blob/M3/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Related: lampepfl/dotty-feature-requests#153