diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-26 16:26:21 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-31 14:47:06 +0100 |
commit | 0fd8804b3a2ce9a2099a3d7c1b756fec637f9d1c (patch) | |
tree | 1ba5ebfdb4de8d0ac969e0765035161b19248bf3 /src/dotty/tools/dotc | |
parent | 0c3a6788ababab2ac10c3dbf76cd3c088ff0582c (diff) | |
download | dotty-0fd8804b3a2ce9a2099a3d7c1b756fec637f9d1c.tar.gz dotty-0fd8804b3a2ce9a2099a3d7c1b756fec637f9d1c.tar.bz2 dotty-0fd8804b3a2ce9a2099a3d7c1b756fec637f9d1c.zip |
Make cloned trees have new uniqueIds
They used to share the same id as the tree they were cloned from,
which makes id's not really unique.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/ast/Trees.scala | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/ast/Trees.scala b/src/dotty/tools/dotc/ast/Trees.scala index 4c63a67ce..9108a4d22 100644 --- a/src/dotty/tools/dotc/ast/Trees.scala +++ b/src/dotty/tools/dotc/ast/Trees.scala @@ -60,15 +60,19 @@ object Trees { with Cloneable { if (Stats.enabled) ntrees += 1 + + private def nxId = { + nextId += 1 + //assert(nextId != 199, this) + nextId + } /** A unique identifier for this tree. Used for debugging, and potentially * tracking presentation compiler interactions */ - val uniqueId = { - nextId += 1 - //assert(nextId != 214, this) - nextId - } + private var myUniqueId: Int = nxId + + def uniqueId = myUniqueId /** The type constructor at the root of the tree */ type ThisTree[T >: Untyped] <: Tree[T] @@ -188,6 +192,12 @@ object Trees { override def hashCode(): Int = uniqueId // for debugging; was: System.identityHashCode(this) override def equals(that: Any) = this eq that.asInstanceOf[AnyRef] + + override def clone: Tree[T] = { + val tree = super.clone.asInstanceOf[Tree[T]] + tree.myUniqueId = nxId + tree + } } class UnAssignedTypeException[T >: Untyped](tree: Tree[T]) extends RuntimeException { |