diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-10-20 22:29:04 +0000 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2011-10-20 22:29:04 +0000 |
commit | d5b81b6cb1f3880a791118609c2d308c34c075f2 (patch) | |
tree | e67554e7045d8edf600b9da76bca743e6b296ee4 /src/compiler/scala/reflect/internal/Trees.scala | |
parent | 8704ed2fc92e3d82287317fe34126c5d4d84e10c (diff) | |
download | scala-d5b81b6cb1f3880a791118609c2d308c34c075f2.tar.gz scala-d5b81b6cb1f3880a791118609c2d308c34c075f2.tar.bz2 scala-d5b81b6cb1f3880a791118609c2d308c34c075f2.zip |
misc fixes while working on virtualizing patter...
misc fixes while working on virtualizing pattern matching not directly
related to pattern matching, though
review by extempore
Diffstat (limited to 'src/compiler/scala/reflect/internal/Trees.scala')
-rw-r--r-- | src/compiler/scala/reflect/internal/Trees.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala index 88eb79c9d8..c469834ac8 100644 --- a/src/compiler/scala/reflect/internal/Trees.scala +++ b/src/compiler/scala/reflect/internal/Trees.scala @@ -279,7 +279,7 @@ trait Trees extends api.Trees { self: SymbolTable => override def traverse(t: Tree) { if (t != EmptyTree && t.pos == NoPosition) { t.setPos(pos) - super.traverse(t) + super.traverse(t) // TODO: bug? shouldn't the traverse be outside of the if? } } } @@ -320,12 +320,15 @@ trait Trees extends api.Trees { self: SymbolTable => "subst[%s, %s](%s)".format(fromStr, toStr, (from, to).zipped map (_ + " -> " + _) mkString ", ") } + // NOTE: if symbols in `from` occur multiple times in the `tree` passed to `transform`, + // the resulting Tree will be a graph, not a tree... this breaks all sorts of stuff, + // notably concerning the mutable aspects of Trees (such as setting their .tpe) class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { override def transform(tree: Tree): Tree = tree match { case Ident(_) => def subst(from: List[Symbol], to: List[Tree]): Tree = if (from.isEmpty) tree - else if (tree.symbol == from.head) to.head + else if (tree.symbol == from.head) to.head.shallowDuplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? else subst(from.tail, to.tail); subst(from, to) case _ => |