@@ -690,9 +690,14 @@ object Trees {
690690 * when type checking. TASTy files will not contain type quotes. Type quotes are used again
691691 * in the `staging` phase to represent the reification of `Type.of[T]]`.
692692 *
693+ * Type tags `tags` are always empty before the `staging` phase. Tags for stage inconsistent
694+ * types are added in the `staging` phase to level 0 quotes. Tags for types that refer to
695+ * definitions in an outer quote are added in the `splicing` phase
696+ *
693697 * @param body The tree that was quoted
698+ * @param tags Term references to instances of `Type[T]` for `T`s that are used in the quote
694699 */
695- case class Quote [+ T <: Untyped ] private [ast] (body : Tree [T ])(implicit @ constructorOnly src : SourceFile )
700+ case class Quote [+ T <: Untyped ] private [ast] (body : Tree [T ], tags : List [ Tree [ T ]] )(implicit @ constructorOnly src : SourceFile )
696701 extends TermTree [T ] {
697702 type ThisTree [+ T <: Untyped ] = Quote [T ]
698703
@@ -1313,9 +1318,9 @@ object Trees {
13131318 case tree : Inlined if (call eq tree.call) && (bindings eq tree.bindings) && (expansion eq tree.expansion) => tree
13141319 case _ => finalize(tree, untpd.Inlined (call, bindings, expansion)(sourceFile(tree)))
13151320 }
1316- def Quote (tree : Tree )(body : Tree )(using Context ): Quote = tree match {
1317- case tree : Quote if (body eq tree.body) => tree
1318- case _ => finalize(tree, untpd.Quote (body)(sourceFile(tree)))
1321+ def Quote (tree : Tree )(body : Tree , tags : List [ Tree ] )(using Context ): Quote = tree match {
1322+ case tree : Quote if (body eq tree.body) && (tags eq tree.tags) => tree
1323+ case _ => finalize(tree, untpd.Quote (body, tags )(sourceFile(tree)))
13191324 }
13201325 def Splice (tree : Tree )(expr : Tree )(using Context ): Splice = tree match {
13211326 case tree : Splice if (expr eq tree.expr) => tree
@@ -1558,8 +1563,8 @@ object Trees {
15581563 case Thicket (trees) =>
15591564 val trees1 = transform(trees)
15601565 if (trees1 eq trees) tree else Thicket (trees1)
1561- case tree @ Quote (body) =>
1562- cpy.Quote (tree)(transform(body)(using quoteContext))
1566+ case Quote (body, tags ) =>
1567+ cpy.Quote (tree)(transform(body)(using quoteContext), transform(tags) )
15631568 case tree @ Splice (expr) =>
15641569 cpy.Splice (tree)(transform(expr)(using spliceContext))
15651570 case tree @ Hole (isTerm, idx, args, content, tpt) =>
@@ -1703,8 +1708,8 @@ object Trees {
17031708 this (this (x, arg), annot)
17041709 case Thicket (ts) =>
17051710 this (x, ts)
1706- case Quote (body) =>
1707- this (x, body)(using quoteContext)
1711+ case Quote (body, tags ) =>
1712+ this (this ( x, body)(using quoteContext), tags )
17081713 case Splice (expr) =>
17091714 this (x, expr)(using spliceContext)
17101715 case Hole (_, _, args, content, tpt) =>
0 commit comments