From 128c23c7880815a02667c2f720896d235ef6a7f8 Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Thu, 23 Jul 2009 03:11:28 +0000 Subject: Fixes for various invalid positions. --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 14 +++++++++----- src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') 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 -- cgit v1.2.3