@@ -503,6 +503,11 @@ object Trees {
503503 def forwardTo : Tree [T ] = fun
504504 }
505505
506+ object GenericApply :
507+ def unapply [T >: Untyped ](tree : Tree [T ]): Option [(Tree [T ], List [Tree [T ]])] = tree match
508+ case tree : GenericApply [T ] => Some ((tree.fun, tree.args))
509+ case _ => None
510+
506511 /** The kind of application */
507512 enum ApplyKind :
508513 case Regular // r.f(x)
@@ -525,8 +530,6 @@ object Trees {
525530 attachmentOrElse(untpd.KindOfApply , ApplyKind .Regular )
526531 }
527532
528-
529-
530533 /** fun[args] */
531534 case class TypeApply [- T >: Untyped ] private [ast] (fun : Tree [T ], args : List [Tree [T ]])(implicit @ constructorOnly src : SourceFile )
532535 extends GenericApply [T ] {
@@ -972,10 +975,16 @@ object Trees {
972975 def genericEmptyValDef [T >: Untyped ]: ValDef [T ] = theEmptyValDef.asInstanceOf [ValDef [T ]]
973976 def genericEmptyTree [T >: Untyped ]: Thicket [T ] = theEmptyTree.asInstanceOf [Thicket [T ]]
974977
975- /** Tree that replaces a splice in pickled quotes.
976- * It is only used when picking quotes (Will never be in a TASTy file).
978+ /** Tree that replaces a level 1 splices in pickled (level 0) quotes.
979+ * It is only used when picking quotes (will never be in a TASTy file).
980+ *
981+ * @param isTermHole If this hole is a term, otherwise it is a type hole.
982+ * @param idx The index of the hole in it's enclosing level 0 quote.
983+ * @param args The arguments of the splice to compute its content
984+ * @param content Lambda that computes the content of the hole. This tree is empty when in a quote pickle.
985+ * @param tpt Type of the hole
977986 */
978- case class Hole [- T >: Untyped ](isTermHole : Boolean , idx : Int , args : List [Tree [T ]])(implicit @ constructorOnly src : SourceFile ) extends Tree [T ] {
987+ case class Hole [- T >: Untyped ](isTermHole : Boolean , idx : Int , args : List [Tree [T ]], content : Tree [ T ], tpt : Tree [ T ] )(implicit @ constructorOnly src : SourceFile ) extends Tree [T ] {
979988 type ThisTree [- T >: Untyped ] <: Hole [T ]
980989 override def isTerm : Boolean = isTermHole
981990 override def isType : Boolean = ! isTermHole
@@ -1331,6 +1340,10 @@ object Trees {
13311340 case tree : Thicket if (trees eq tree.trees) => tree
13321341 case _ => finalize(tree, untpd.Thicket (trees)(sourceFile(tree)))
13331342 }
1343+ def Hole (tree : Tree )(isTerm : Boolean , idx : Int , args : List [Tree ], content : Tree , tpt : Tree )(using Context ): Hole = tree match {
1344+ case tree : Hole if isTerm == tree.isTerm && idx == tree.idx && args.eq(tree.args) && content.eq(tree.content) && content.eq(tree.content) => tree
1345+ case _ => finalize(tree, untpd.Hole (isTerm, idx, args, content, tpt)(sourceFile(tree)))
1346+ }
13341347
13351348 // Copier methods with default arguments; these demand that the original tree
13361349 // is of the same class as the copy. We only include trees with more than 2 elements here.
@@ -1352,6 +1365,9 @@ object Trees {
13521365 TypeDef (tree : Tree )(name, rhs)
13531366 def Template (tree : Template )(constr : DefDef = tree.constr, parents : List [Tree ] = tree.parents, derived : List [untpd.Tree ] = tree.derived, self : ValDef = tree.self, body : LazyTreeList = tree.unforcedBody)(using Context ): Template =
13541367 Template (tree : Tree )(constr, parents, derived, self, body)
1368+ def Hole (tree : Hole )(isTerm : Boolean = tree.isTerm, idx : Int = tree.idx, args : List [Tree ] = tree.args, content : Tree = tree.content, tpt : Tree = tree.tpt)(using Context ): Hole =
1369+ Hole (tree : Tree )(isTerm, idx, args, content, tpt)
1370+
13551371 }
13561372
13571373 /** Hook to indicate that a transform of some subtree should be skipped */
@@ -1481,6 +1497,8 @@ object Trees {
14811497 case Thicket (trees) =>
14821498 val trees1 = transform(trees)
14831499 if (trees1 eq trees) tree else Thicket (trees1)
1500+ case tree @ Hole (_, _, args, content, tpt) =>
1501+ cpy.Hole (tree)(args = transform(args), content = transform(content), tpt = transform(tpt))
14841502 case _ =>
14851503 transformMoreCases(tree)
14861504 }
@@ -1620,8 +1638,8 @@ object Trees {
16201638 this (this (x, arg), annot)
16211639 case Thicket (ts) =>
16221640 this (x, ts)
1623- case Hole (_, _, args) =>
1624- this (x, args)
1641+ case Hole (_, _, args, content, tpt ) =>
1642+ this (this ( this ( x, args), content), tpt )
16251643 case _ =>
16261644 foldMoreCases(x, tree)
16271645 }
0 commit comments