@@ -87,8 +87,7 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
87
87
88
88
/**
89
89
* A mutable map for holding auxiliary information of this tree node. It will be carried over
90
- * when this node is copied via `makeCopy`. The tags will be kept after transforming, if
91
- * the node is transformed to the same type. Otherwise, tags will be dropped.
90
+ * when this node is copied via `makeCopy`, or transformed via `transformUp`/`transformDown`.
92
91
*/
93
92
val tags : mutable.Map [TreeNodeTagName , Any ] = mutable.Map .empty
94
93
@@ -273,12 +272,8 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
273
272
if (this fastEquals afterRule) {
274
273
mapChildren(_.transformDown(rule))
275
274
} else {
276
- // If the transform function replaces this node with a new one of the same type, carry over
277
- // the tags.
278
- if (afterRule.getClass == this .getClass) {
279
- afterRule.tags ++= this .tags
280
- }
281
-
275
+ // If the transform function replaces this node with a new one, carry over the tags.
276
+ afterRule.tags ++= this .tags
282
277
afterRule.mapChildren(_.transformDown(rule))
283
278
}
284
279
}
@@ -301,11 +296,8 @@ abstract class TreeNode[BaseType <: TreeNode[BaseType]] extends Product {
301
296
rule.applyOrElse(afterRuleOnChildren, identity[BaseType ])
302
297
}
303
298
}
304
- // If the transform function replaces this node with a new one of the same type, carry over
305
- // the tags.
306
- if (newNode.getClass == this .getClass) {
307
- newNode.tags ++= this .tags
308
- }
299
+ // If the transform function replaces this node with a new one, carry over the tags.
300
+ newNode.tags ++= this .tags
309
301
newNode
310
302
}
311
303
0 commit comments