diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/Trees.scala | 7 | ||||
-rw-r--r-- | tests/pos/i2056.scala | 13 |
2 files changed, 18 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 = diff --git a/tests/pos/i2056.scala b/tests/pos/i2056.scala new file mode 100644 index 000000000..c4d020fb6 --- /dev/null +++ b/tests/pos/i2056.scala @@ -0,0 +1,13 @@ +object Test { + inline def crash() = { + try { + println("hi") + } catch { + case e: Exception => + } + } + + def main(args: Array[String]): Unit = { + crash() + } +} |