From b47189ad06e027c310d93b071fc8bf15d979225d Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Mon, 23 Apr 2012 06:12:57 -0700 Subject: Fix for range positions. You are a fireman, leading a team of firemen on a rescue in a burning building. When you have cleared a room, you place a sticker on the door which says "Room cleared!" If the other firemen see that sticker, they will skip that room, knowing there are no small children or adorable puppies behind it. As the lead fireman, here is what you should not do: run from door to door slapping "Room cleared!" stickers on them all, so the other firemen shrug and go home. Translation: when recursion depends on a condition, if you alter the condition before you recurse, you may not recurse at all. --- src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala index 88cea2231f..838c7f8abd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala +++ b/src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala @@ -1020,7 +1020,12 @@ class Foo(x: Other) { x._1 } // no error in this order override def traverse(t: Tree) { if (t != EmptyTree && t.pos == NoPosition) { - t.setPos(pos) + t setPos pos + // During a recursive descent traversal which prunes when it sees + // a position, one can't assign the position and THEN recurse. + // Ensuring that all children have compliant range positions. + for (t1 <- t ; if t1 ne t) + t1 setPos pos.makeTransparent } t match { case Function(_, _) if t.symbol == NoSymbol => -- cgit v1.2.3