diff options
author | Paul Phillips <paulp@improving.org> | 2012-04-23 06:12:57 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-04-23 06:20:25 -0700 |
commit | b47189ad06e027c310d93b071fc8bf15d979225d (patch) | |
tree | 14761012df05e3685eb3fbcb6dc45aa12e642b27 | |
parent | 8c95273b70288e4e3a547fa43f2dbdb40a71b9ea (diff) | |
download | scala-b47189ad06e027c310d93b071fc8bf15d979225d.tar.gz scala-b47189ad06e027c310d93b071fc8bf15d979225d.tar.bz2 scala-b47189ad06e027c310d93b071fc8bf15d979225d.zip |
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.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/PatMatVirtualiser.scala | 7 |
1 files changed, 6 insertions, 1 deletions
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 => |