@@ -737,13 +737,18 @@ object Trees {
737
737
type ThisTree [+ T <: Untyped ] = Splice [T ]
738
738
}
739
739
740
+ case class QuotePattern [+ T <: Untyped ] private [ast] (bindings : List [Tree [T ]], body : Tree [T ], quotes : Tree [T ])(implicit @ constructorOnly src : SourceFile )
741
+ extends PatternTree [T ] {
742
+ type ThisTree [+ T <: Untyped ] = QuotePattern [T ]
743
+ }
744
+
740
745
/** A tree representing a pattern splice `${ pattern }`, `$ident` or `$ident(args*)` in a quote pattern.
741
746
*
742
747
* Parser will only create `${ pattern }` and `$ident`, hence they will not have args.
743
748
* While typing, the `$ident(args*)` the args are identified and desugared into a `SplicePattern`
744
749
* containing them.
745
750
*
746
- * SplicePattern are removed after typing the pattern and are not present in TASTy.
751
+ * SplicePattern are removed after typing the pattern and are not present in TASTy. (TODO update)
747
752
*
748
753
* @param body The tree that was spliced
749
754
* @param args The arguments of the splice (the HOAS arguments)
@@ -1163,6 +1168,7 @@ object Trees {
1163
1168
type Inlined = Trees .Inlined [T ]
1164
1169
type Quote = Trees .Quote [T ]
1165
1170
type Splice = Trees .Splice [T ]
1171
+ type QuotePattern = Trees .QuotePattern [T ]
1166
1172
type SplicePattern = Trees .SplicePattern [T ]
1167
1173
type TypeTree = Trees .TypeTree [T ]
1168
1174
type InferredTypeTree = Trees .InferredTypeTree [T ]
@@ -1342,6 +1348,10 @@ object Trees {
1342
1348
case tree : Splice if (expr eq tree.expr) => tree
1343
1349
case _ => finalize(tree, untpd.Splice (expr)(sourceFile(tree)))
1344
1350
}
1351
+ def QuotePattern (tree : Tree )(bindings : List [Tree ], body : Tree , quotes : Tree )(using Context ): QuotePattern = tree match {
1352
+ case tree : QuotePattern if (bindings eq tree.bindings) && (body eq tree.body) && (quotes eq tree.quotes) => tree
1353
+ case _ => finalize(tree, untpd.QuotePattern (bindings, body, quotes)(sourceFile(tree)))
1354
+ }
1345
1355
def SplicePattern (tree : Tree )(body : Tree , args : List [Tree ])(using Context ): SplicePattern = tree match {
1346
1356
case tree : SplicePattern if (body eq tree.body) && (args eq tree.args) => tree
1347
1357
case _ => finalize(tree, untpd.SplicePattern (body, args)(sourceFile(tree)))
@@ -1587,6 +1597,8 @@ object Trees {
1587
1597
cpy.Quote (tree)(transform(body)(using quoteContext), transform(tags))
1588
1598
case tree @ Splice (expr) =>
1589
1599
cpy.Splice (tree)(transform(expr)(using spliceContext))
1600
+ case tree @ QuotePattern (bindings, body, quotes) =>
1601
+ cpy.QuotePattern (tree)(transform(bindings), transform(body)(using quoteContext), transform(quotes))
1590
1602
case tree @ SplicePattern (body, args) =>
1591
1603
cpy.SplicePattern (tree)(transform(body)(using spliceContext), transform(args))
1592
1604
case tree @ Hole (isTerm, idx, args, content) =>
@@ -1734,6 +1746,8 @@ object Trees {
1734
1746
this (this (x, body)(using quoteContext), tags)
1735
1747
case Splice (expr) =>
1736
1748
this (x, expr)(using spliceContext)
1749
+ case QuotePattern (bindings, body, quotes) =>
1750
+ this (this (this (x, bindings), body)(using quoteContext), quotes)
1737
1751
case SplicePattern (body, args) =>
1738
1752
this (this (x, body)(using spliceContext), args)
1739
1753
case Hole (_, _, args, content) =>
0 commit comments