summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-01-03 20:17:30 +0000
committerPaul Phillips <paulp@improving.org>2011-01-03 20:17:30 +0000
commitd891167c880d56c38d145d19e2f825ec908eec61 (patch)
treef135fef0b4baf35efa4e4510277fc4c6c608b986 /src/compiler
parent4f9b1cf852a62fc5ec7cd2dd9a36f7d6391f58fb (diff)
downloadscala-d891167c880d56c38d145d19e2f825ec908eec61.tar.gz
scala-d891167c880d56c38d145d19e2f825ec908eec61.tar.bz2
scala-d891167c880d56c38d145d19e2f825ec908eec61.zip
Some minor Tree optimizations. No review.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/Trees.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala
index 7f52d40053..ecba1c23da 100644
--- a/src/compiler/scala/tools/nsc/ast/Trees.scala
+++ b/src/compiler/scala/tools/nsc/ast/Trees.scala
@@ -89,8 +89,7 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
def equalsStructure(that : Tree) = equalsStructure0(that)(_ eq _)
def equalsStructure0(that: Tree)(f: (Tree,Tree) => Boolean): Boolean =
- (tree == that) || ((tree.getClass == that.getClass) && { // XXX defining any kind of equality in terms of getClass is a mistake
- assert(tree.productArity == that.productArity)
+ f(tree, that) || ((tree.productArity == that.productArity) && {
def equals0(this0: Any, that0: Any): Boolean = (this0, that0) match {
case (x: Tree, y: Tree) => f(x, y) || (x equalsStructure0 y)(f)
case (xs: List[_], ys: List[_]) => (xs corresponds ys)(equals0)
@@ -103,7 +102,7 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
true
}
- (tree.productIterator.toList corresponds that.productIterator.toList)(equals0) && compareOriginals()
+ (tree.productIterator zip that.productIterator forall { case (x, y) => equals0(x, y) }) && compareOriginals()
})
def shallowDuplicate: Tree = new ShallowDuplicator(tree) transform tree
@@ -948,6 +947,8 @@ trait Trees extends reflect.generic.Trees { self: SymbolTable =>
class TreeTypeSubstituter(val from: List[Symbol], val to: List[Type]) extends Traverser {
val typeSubst = new SubstTypeMap(from, to)
+ def fromContains = typeSubst.fromContains
+
override def traverse(tree: Tree) {
if (tree.tpe ne null) tree.tpe = typeSubst(tree.tpe)
if (tree.isDef) {