summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMiles Sabin <miles@milessabin.com>2009-07-23 03:11:28 +0000
committerMiles Sabin <miles@milessabin.com>2009-07-23 03:11:28 +0000
commit128c23c7880815a02667c2f720896d235ef6a7f8 (patch)
tree6e4091a67d7a918e0ba00458193378569d5a5d16 /src/compiler
parent9dfe628e0fcdcaa6f53b44dac11284a782c3b97f (diff)
downloadscala-128c23c7880815a02667c2f720896d235ef6a7f8.tar.gz
scala-128c23c7880815a02667c2f720896d235ef6a7f8.tar.bz2
scala-128c23c7880815a02667c2f720896d235ef6a7f8.zip
Fixes for various invalid positions.
Diffstat (limited to 'src/compiler')
-rwxr-xr-xsrc/compiler/scala/tools/nsc/ast/parser/Parsers.scala14
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala6
2 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 55aa4acf7d..d28f9424fe 100755
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -867,7 +867,8 @@ self =>
def wildcardType(start: Int) = {
val pname = freshName(o2p(start), "_$").toTypeName
val t = atPos(start) { Ident(pname) }
- val param = atPos(t2p(t)) { makeSyntheticTypeParam(pname, typeBounds()) }
+ val bounds = typeBounds()
+ val param = atPos(t.pos union bounds.pos) { makeSyntheticTypeParam(pname, bounds) }
placeholderTypes = param :: placeholderTypes
t
}
@@ -1822,10 +1823,13 @@ self =>
/** TypeBounds ::= [`>:' Type] [`<:' Type]
*/
- def typeBounds(): TypeBoundsTree =
- TypeBoundsTree(
+ def typeBounds(): TypeBoundsTree = {
+ val t = TypeBoundsTree(
bound(SUPERTYPE, nme.Nothing),
bound(SUBTYPE, nme.Any))
+ t setPos (t.hi.pos union t.lo.pos)
+ t
+ }
def bound(tok: Int, default: Name): Tree =
if (in.token == tok) { in.nextToken(); typ() }
@@ -2422,11 +2426,11 @@ self =>
if (in.token == ARROW) {
first match {
case Typed(tree @ This(name), tpt) if (name == nme.EMPTY.toTypeName) =>
- self = atPos(tree.pos) { makeSelfDef(nme.WILDCARD, tpt) }
+ self = atPos(tree.pos union tpt.pos) { makeSelfDef(nme.WILDCARD, tpt) }
case _ =>
convertToParam(first) match {
case tree @ ValDef(_, name, tpt, EmptyTree) if (name != nme.ERROR) =>
- self = atPos(tree.pos) { makeSelfDef(name, tpt) }
+ self = atPos(tree.pos union tpt.pos) { makeSelfDef(name, tpt) }
case _ =>
}
}
diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
index ca51c9aa5c..78969e7e15 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala
@@ -201,7 +201,7 @@ abstract class TreeBuilder {
/** Create tree representing a do-while loop */
def makeDoWhile(lname: Name, body: Tree, cond: Tree): Tree = {
val continu = Apply(Ident(lname), Nil)
- val rhs = Block(List(body), atPos(o2p(body.pos.end)) { If(cond, continu, Literal(())) })
+ val rhs = Block(List(body), If(cond, continu, Literal(())))
LabelDef(lname, Nil, rhs)
}
@@ -368,9 +368,9 @@ abstract class TreeBuilder {
val ids = (defpat1 :: defpats) map makeValue
val rhs1 = makeForYield(
List(ValFrom(pos, defpat1, rhs)),
- Block(pdefs, makeTupleTerm(ids, true) setPos wrappingPos(ids)) setPos wrappingPos(pdefs))
+ Block(pdefs, atPos(wrappingPos(ids)) { makeTupleTerm(ids, true) }) setPos wrappingPos(pdefs))
val allpats = (pat :: pats) map (_.syntheticDuplicate)
- val vfrom1 = ValFrom(r2p(pos.start, pos.point, rhs1.pos.end), makeTuple(allpats, false), rhs1)
+ val vfrom1 = ValFrom(r2p(pos.start, pos.point, rhs1.pos.end), atPos(wrappingPos(allpats)) { makeTuple(allpats, false) } , rhs1)
makeFor(mapName, flatMapName, vfrom1 :: rest1, body)
case _ =>
EmptyTree //may happen for erroneous input