diff options
author | Paul Phillips <paulp@improving.org> | 2013-04-30 01:01:53 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-04-30 01:11:14 -0700 |
commit | d0a1f5b1c4d97f3e0368dc89691097a1b836a116 (patch) | |
tree | 6431083355f93f10f02b6e09223a896877cb1910 /src | |
parent | 3da1abe3a2e2752588ca8e2c7e889a321dae2037 (diff) | |
download | scala-d0a1f5b1c4d97f3e0368dc89691097a1b836a116.tar.gz scala-d0a1f5b1c4d97f3e0368dc89691097a1b836a116.tar.bz2 scala-d0a1f5b1c4d97f3e0368dc89691097a1b836a116.zip |
SI-7385 crash in erroneous code
Less crashing, more emitting errors.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala | 9 |
2 files changed, 8 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 6f79f639b9..b05902a6ef 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1332,11 +1332,10 @@ self => def parseWhile = { val start = in.offset atPos(in.skipToken()) { - val lname: Name = freshTermName(nme.WHILE_PREFIX) val cond = condExpr() newLinesOpt() val body = expr() - makeWhile(lname, cond, body) + makeWhile(start, cond, body) } } parseWhile diff --git a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala index cd93221c50..b5771454f8 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala @@ -251,8 +251,13 @@ abstract class TreeBuilder { else CompoundTypeTree(Template(tps, emptyValDef, Nil)) /** Create tree representing a while loop */ - def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { - val continu = atPos(o2p(body.pos pointOrElse wrappingPos(List(cond, body)).pos.endOrPoint)) { Apply(Ident(lname), Nil) } + def makeWhile(startPos: Int, cond: Tree, body: Tree): Tree = { + val lname = freshTermName(nme.WHILE_PREFIX) + def default = wrappingPos(List(cond, body)) match { + case p if p.isDefined => p.endOrPoint + case _ => startPos + } + val continu = atPos(o2p(body.pos pointOrElse default)) { Apply(Ident(lname), Nil) } val rhs = If(cond, Block(List(body), continu), Literal(Constant())) LabelDef(lname, Nil, rhs) } |