@@ -119,56 +119,56 @@ class ReifyQuotes extends MacroTransform {
119
119
new QuoteReifier (this , capturers, nestedEmbedded, ctx.owner)(ctx)
120
120
}
121
121
122
- /** Assuming <expr> contains types `${<tag1>}, ..., ${<tagN>}`, the expression
123
- *
124
- * { @quoteTypeTag type <Type1> = ${<tag1>}
125
- * ...
126
- * @quoteTypeTag type <TypeN> = ${<tagN>}
127
- * <expr>
128
- * }
129
- *
130
- * references to `TypeI` in `expr` are rewired to point to the locally
131
- * defined versions. As a side effect, prepend the expressions `tag1, ..., `tagN`
132
- * as splices.
133
- */
134
- private def addTags (expr : Tree )(implicit ctx : Context ): Tree = {
135
-
136
- def mkTagSymbolAndAssignType (spliced : TermRef ): TypeDef = {
137
- val splicedTree = tpd.ref(spliced).withSpan(expr.span)
138
- val rhs = transform(splicedTree.select(tpnme.splice))
139
- val alias = ctx.typeAssigner.assignType(untpd.TypeBoundsTree (rhs, rhs), rhs, rhs, EmptyTree )
140
- val local = ctx.newSymbol(
141
- owner = ctx.owner,
142
- name = UniqueName .fresh((splicedTree.symbol.name.toString + " $_" ).toTermName).toTypeName,
143
- flags = Synthetic ,
144
- info = TypeAlias (splicedTree.tpe.select(tpnme.splice)),
145
- coord = spliced.termSymbol.coord).asType
146
- local.addAnnotation(Annotation (defn.InternalQuoted_QuoteTypeTagAnnot ))
147
- ctx.typeAssigner.assignType(untpd.TypeDef (local.name, alias), local)
148
- }
149
-
150
- val tagDefCache = new mutable.LinkedHashMap [Symbol , TypeDef ]()
151
-
152
- def typeTagMap = new TypeMap () {
153
- def apply (tp : Type ): Type = tp match {
154
- case tp : TypeRef if tp.symbol.isSplice =>
155
- tp.prefix match {
156
- case prefix : TermRef =>
157
- val tagDef = tagDefCache.getOrElseUpdate(prefix.symbol, mkTagSymbolAndAssignType(prefix))
158
- tagDef.symbol.typeRef
159
- }
160
- case AnnotatedType (parent, _) =>
161
- apply(parent) // Only keep the Annotated tree
162
- case _ =>
163
- mapOver(tp)
164
- }
165
- }
166
-
167
- val tagedTree = new TreeTypeMap (typeMap = typeTagMap).apply(expr)
168
-
169
- if (tagDefCache.isEmpty) expr
170
- else Block (tagDefCache.valuesIterator.toList, tagedTree)
171
- }
122
+ // / ** Assuming <expr> contains types `${<tag1>}, ..., ${<tagN>}`, the expression
123
+ // *
124
+ // * { @quoteTypeTag type <Type1> = ${<tag1>}
125
+ // * ...
126
+ // * @quoteTypeTag type <TypeN> = ${<tagN>}
127
+ // * <expr>
128
+ // * }
129
+ // *
130
+ // * references to `TypeI` in `expr` are rewired to point to the locally
131
+ // * defined versions. As a side effect, prepend the expressions `tag1, ..., `tagN`
132
+ // * as splices.
133
+ // */
134
+ // private def addTags(expr: Tree)(implicit ctx: Context): Tree = {
135
+
136
+ // def mkTagSymbolAndAssignType(spliced: TermRef): TypeDef = {
137
+ // val splicedTree = tpd.ref(spliced).withSpan(expr.span)
138
+ // val rhs = transform(splicedTree.select(tpnme.splice))
139
+ // val alias = ctx.typeAssigner.assignType(untpd.TypeBoundsTree(rhs, rhs), rhs, rhs, EmptyTree)
140
+ // val local = ctx.newSymbol(
141
+ // owner = ctx.owner,
142
+ // name = UniqueName.fresh((splicedTree.symbol.name.toString + "$_").toTermName).toTypeName,
143
+ // flags = Synthetic,
144
+ // info = TypeAlias(splicedTree.tpe.select(tpnme.splice)),
145
+ // coord = spliced.termSymbol.coord).asType
146
+ // local.addAnnotation(Annotation(defn.InternalQuoted_QuoteTypeTagAnnot))
147
+ // ctx.typeAssigner.assignType(untpd.TypeDef(local.name, alias), local)
148
+ // }
149
+
150
+ // val tagDefCache = new mutable.LinkedHashMap[Symbol, TypeDef]()
151
+
152
+ // def typeTagMap = new TypeMap() {
153
+ // def apply(tp: Type): Type = tp match {
154
+ // case tp: TypeRef if tp.symbol.isSplice =>
155
+ // tp.prefix match {
156
+ // case prefix: TermRef =>
157
+ // val tagDef = tagDefCache.getOrElseUpdate(prefix.symbol, mkTagSymbolAndAssignType(prefix))
158
+ // tagDef.symbol.typeRef
159
+ // }
160
+ // case AnnotatedType(parent, _) =>
161
+ // apply(parent) // Only keep the Annotated tree
162
+ // case _ =>
163
+ // mapOver(tp)
164
+ // }
165
+ // }
166
+
167
+ // val tagedTree = new TreeTypeMap(typeMap = typeTagMap).apply(expr)
168
+
169
+ // if (tagDefCache.isEmpty) expr
170
+ // else Block(tagDefCache.valuesIterator.toList, tagedTree)
171
+ // }
172
172
173
173
/** Split `body` into a core and a list of embedded splices.
174
174
* Then if inside a splice, make a hole from these parts.
@@ -365,10 +365,10 @@ class ReifyQuotes extends MacroTransform {
365
365
level == 1 && levelOf(sym).contains(1 ) && capturers.contains(sym)
366
366
367
367
/** Transform `tree` and return the resulting tree and all `embedded` quotes
368
- * or splices as a pair, after performing the `addTags` transform .
368
+ * or splices as a pair.
369
369
*/
370
370
private def splitQuote (tree : Tree )(implicit ctx : Context ): (Tree , List [Tree ]) = {
371
- val tree1 = addTags( transform(tree) )
371
+ val tree1 = transform(tree)
372
372
(tree1, embedded.getTrees)
373
373
}
374
374
0 commit comments