@@ -975,6 +975,23 @@ object Trees {
975975 def genericEmptyValDef [T <: Untyped ]: ValDef [T ] = theEmptyValDef.asInstanceOf [ValDef [T ]]
976976 def genericEmptyTree [T <: Untyped ]: Thicket [T ] = theEmptyTree.asInstanceOf [Thicket [T ]]
977977
978+ /** Tree that replaces a level 1 splices in pickled (level 0) quotes.
979+ * It is only used when encoding pickled quotes. These will be encoded
980+ * as PickledHole when pickled.
981+ *
982+ * @param isTermHole If this hole is a term, otherwise it is a type hole.
983+ * @param idx The index of the hole in it's enclosing level 0 quote.
984+ * @param targs The type arguments of the splice to compute its content
985+ * @param args The term (or type) arguments of the splice to compute its content
986+ * @param tpt Type of the hole
987+ * @param content Lambda that computes the content of the hole. This tree is empty when in a quote pickle.
988+ */
989+ case class Hole [+ T <: Untyped ](isTermHole : Boolean , idx : Int , targs : List [Tree [T ]], args : List [Tree [T ]], content : Tree [T ], tpt : Tree [T ])(implicit @ constructorOnly src : SourceFile ) extends Tree [T ] {
990+ type ThisTree [+ T <: Untyped ] <: Hole [T ]
991+ override def isTerm : Boolean = isTermHole
992+ override def isType : Boolean = ! isTermHole
993+ }
994+
978995 /** Tree that replaces a level 1 splices in pickled (level 0) quotes.
979996 * It is only used when picking quotes (will never be in a TASTy file).
980997 *
@@ -986,13 +1003,11 @@ object Trees {
9861003 *
9871004 * @param isTermHole If this hole is a term, otherwise it is a type hole.
9881005 * @param idx The index of the hole in it's enclosing level 0 quote.
989- * @param targs The type arguments of the splice to compute its content
9901006 * @param args The term (or type) arguments of the splice to compute its content
9911007 * @param tpt Type of the hole
992- * @param content Lambda that computes the content of the hole. This tree is empty when in a quote pickle.
9931008 */
994- case class Hole [+ T <: Untyped ](isTermHole : Boolean , idx : Int , targs : List [ Tree [ T ]], args : List [Tree [T ]], content : Tree [ T ], tpt : Tree [T ])(implicit @ constructorOnly src : SourceFile ) extends Tree [T ] {
995- type ThisTree [+ T <: Untyped ] <: Hole [T ]
1009+ case class PickledHole [+ T <: Untyped ](isTermHole : Boolean , idx : Int , args : List [Tree [T ]], tpt : Tree [T ])(implicit @ constructorOnly src : SourceFile ) extends Tree [T ] {
1010+ type ThisTree [+ T <: Untyped ] <: PickledHole [T ]
9961011 override def isTerm : Boolean = isTermHole
9971012 override def isType : Boolean = ! isTermHole
9981013 }
@@ -1119,6 +1134,7 @@ object Trees {
11191134 type Thicket = Trees .Thicket [T ]
11201135
11211136 type Hole = Trees .Hole [T ]
1137+ type PickledHole = Trees .PickledHole [T ]
11221138
11231139 @ sharable val EmptyTree : Thicket = genericEmptyTree
11241140 @ sharable val EmptyValDef : ValDef = genericEmptyValDef
@@ -1345,9 +1361,13 @@ object Trees {
13451361 case _ => finalize(tree, untpd.Thicket (trees)(sourceFile(tree)))
13461362 }
13471363 def Hole (tree : Tree )(isTerm : Boolean , idx : Int , targs : List [Tree ], args : List [Tree ], content : Tree , tpt : Tree )(using Context ): Hole = tree match {
1348- case tree : Hole if isTerm == tree.isTerm && idx == tree.idx && targs.eq(tree.targs) && args.eq(tree.args) && content.eq(tree.content) && content .eq(tree.content ) => tree
1364+ case tree : Hole if isTerm == tree.isTerm && idx == tree.idx && targs.eq(tree.targs) && args.eq(tree.args) && content.eq(tree.content) && tpt .eq(tree.tpt ) => tree
13491365 case _ => finalize(tree, untpd.Hole (isTerm, idx, targs, args, content, tpt)(sourceFile(tree)))
13501366 }
1367+ def PickledHole (tree : Tree )(isTerm : Boolean , idx : Int , args : List [Tree ], tpt : Tree )(using Context ): PickledHole = tree match {
1368+ case tree : PickledHole if isTerm == tree.isTerm && idx == tree.idx && args.eq(tree.args) && tpt.eq(tree.tpt) => tree
1369+ case _ => finalize(tree, untpd.PickledHole (isTerm, idx, args, tpt)(sourceFile(tree)))
1370+ }
13511371
13521372 // Copier methods with default arguments; these demand that the original tree
13531373 // is of the same class as the copy. We only include trees with more than 2 elements here.
@@ -1371,6 +1391,8 @@ object Trees {
13711391 Template (tree : Tree )(constr, parents, derived, self, body)
13721392 def Hole (tree : Hole )(isTerm : Boolean = tree.isTerm, idx : Int = tree.idx, targs : List [Tree ] = tree.targs, args : List [Tree ] = tree.args, content : Tree = tree.content, tpt : Tree = tree.tpt)(using Context ): Hole =
13731393 Hole (tree : Tree )(isTerm, idx, targs, args, content, tpt)
1394+ def PickledHole (tree : PickledHole )(isTerm : Boolean = tree.isTerm, idx : Int = tree.idx, args : List [Tree ] = tree.args, tpt : Tree = tree.tpt)(using Context ): PickledHole =
1395+ PickledHole (tree : Tree )(isTerm, idx, args, tpt)
13741396
13751397 }
13761398
@@ -1503,6 +1525,8 @@ object Trees {
15031525 if (trees1 eq trees) tree else Thicket (trees1)
15041526 case tree @ Hole (_, _, targs, args, content, tpt) =>
15051527 cpy.Hole (tree)(targs = transform(targs), args = transform(args), content = transform(content), tpt = transform(tpt))
1528+ case tree @ PickledHole (_, _, args, tpt) =>
1529+ cpy.PickledHole (tree)(args = transform(args), tpt = transform(tpt))
15061530 case _ =>
15071531 transformMoreCases(tree)
15081532 }
@@ -1644,6 +1668,8 @@ object Trees {
16441668 this (x, ts)
16451669 case Hole (_, _, targs, args, content, tpt) =>
16461670 this (this (this (this (x, targs), args), content), tpt)
1671+ case PickledHole (_, _, args, tpt) =>
1672+ this (this (x, args), tpt)
16471673 case _ =>
16481674 foldMoreCases(x, tree)
16491675 }
0 commit comments