diff options
author | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-05-15 09:40:23 +0200 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-07-30 10:17:47 +0200 |
commit | 0152dbe969520914ce1730c4a81597bc362c9c5b (patch) | |
tree | 7142b8f05d68cbe678b03afd669abdd997786b87 /src/compiler/scala/tools/nsc/ast/Trees.scala | |
parent | 1ad6e501997d332e2bc0ccc8dd40e3909e728930 (diff) | |
download | scala-0152dbe969520914ce1730c4a81597bc362c9c5b.tar.gz scala-0152dbe969520914ce1730c4a81597bc362c9c5b.tar.bz2 scala-0152dbe969520914ce1730c4a81597bc362c9c5b.zip |
Fixed SI-5603. Early definitions now get transparent positions.
This includes a fix for a minor problem described in #594 -
ensureNonOverlapping still focuses on default position when outside of early defs.
Review by @dragos, @odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/Trees.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/Trees.scala | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 1d29e33c50..9a6d32be01 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -95,11 +95,12 @@ trait Trees extends reflect.internal.Trees { self: Global => val (edefs, rest) = body span treeInfo.isEarlyDef val (evdefs, etdefs) = edefs partition treeInfo.isEarlyValDef val gvdefs = evdefs map { - case vdef @ ValDef(_, _, tpt, _) => copyValDef(vdef)( - // !!! I know "atPos in case" wasn't intentionally planted to - // add an air of mystery to this file, but it is the sort of - // comment which only its author could love. - tpt = atPos(vdef.pos.focus)(TypeTree() setOriginal tpt setPos tpt.pos.focus), // atPos in case + case vdef @ ValDef(_, _, tpt, _) => + copyValDef(vdef)( + // atPos for the new tpt is necessary, since the original tpt might have no position + // (when missing type annotation for ValDef for example), so even though setOriginal modifies the + // position of TypeTree, it would still be NoPosition. That's what the author meant. + tpt = atPos(vdef.pos.focus)(TypeTree() setOriginal tpt setPos tpt.pos.focus), rhs = EmptyTree ) } @@ -125,7 +126,7 @@ trait Trees extends reflect.internal.Trees { self: Global => DefDef(constrMods, nme.CONSTRUCTOR, List(), vparamss1, TypeTree(), Block(lvdefs ::: List(superCall), Literal(Constant()))))) } } - constrs foreach (ensureNonOverlapping(_, parents ::: gvdefs)) + constrs foreach (ensureNonOverlapping(_, parents ::: gvdefs, focus=false)) // Field definitions for the class - remove defaults. val fieldDefs = vparamss.flatten map (vd => copyValDef(vd)(mods = vd.mods &~ DEFAULTPARAM, rhs = EmptyTree)) |