diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2017-03-07 13:13:27 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2017-03-07 13:21:29 +0100 |
commit | 094cd9ff3b07536f75f3a233606823ae5478d542 (patch) | |
tree | e6309f4df17f9b91cbf46482762146b8ff0741ae /compiler/src | |
parent | 06d3f7aefa620ce006008955203d7f8f8dc7b605 (diff) | |
download | dotty-094cd9ff3b07536f75f3a233606823ae5478d542.tar.gz dotty-094cd9ff3b07536f75f3a233606823ae5478d542.tar.bz2 dotty-094cd9ff3b07536f75f3a233606823ae5478d542.zip |
Fix #2056: Backend crash when inlined method contains try
In various places we do "case EmptyTree =>", since Tree#equals uses
reference equality this means that EmptyTree should never be copied,
otherwise some other code path will be taken.
Diffstat (limited to 'compiler/src')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/Trees.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Trees.scala b/compiler/src/dotty/tools/dotc/ast/Trees.scala index 27be8c9d6..669e5429c 100644 --- a/compiler/src/dotty/tools/dotc/ast/Trees.scala +++ b/compiler/src/dotty/tools/dotc/ast/Trees.scala @@ -712,8 +712,11 @@ object Trees { override def toList: List[Tree[T]] = flatten(trees) override def toString = if (isEmpty) "EmptyTree" else "Thicket(" + trees.mkString(", ") + ")" override def withPos(pos: Position): this.type = { - val newTrees = trees.map(_.withPos(pos)) - new Thicket[T](newTrees).asInstanceOf[this.type] + val newTrees = trees.mapConserve(_.withPos(pos)) + if (trees eq newTrees) + this + else + new Thicket[T](newTrees).asInstanceOf[this.type] } override def pos = (NoPosition /: trees) ((pos, t) => pos union t.pos) override def foreachInThicket(op: Tree[T] => Unit): Unit = |