summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorMiles Sabin <miles@milessabin.com>2010-05-11 12:42:21 +0000
committerMiles Sabin <miles@milessabin.com>2010-05-11 12:42:21 +0000
commit582c53207bb7eda2cde2070db1ee42691dcfb33e (patch)
treebc6a28d379a062f3e7f31fbf6dbba292a4684494 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parent180c6d047dbe16d5a2d4ec9186aad749e64e012d (diff)
downloadscala-582c53207bb7eda2cde2070db1ee42691dcfb33e.tar.gz
scala-582c53207bb7eda2cde2070db1ee42691dcfb33e.tar.bz2
scala-582c53207bb7eda2cde2070db1ee42691dcfb33e.zip
Fix from Mirko Stocker and unit test for #3416.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index 497cfc398b..43e515d31e 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1906,13 +1906,19 @@ self =>
*/
def importClause(): List[Tree] = {
val offset = accept(IMPORT)
- commaSeparated(importExpr(offset))
+ commaSeparated(importExpr()) match {
+ case Nil => Nil
+ case t :: rest =>
+ // The first import should start at the position of the keyword.
+ t.setPos(t.pos.withStart(offset))
+ t :: rest
+ }
}
/** ImportExpr ::= StableId `.' (Id | `_' | ImportSelectors)
* XXX: Hook for IDE
*/
- def importExpr(importOffset: Int): Tree = {
+ def importExpr(): Tree = {
val start = in.offset
var t: Tree = null
if (in.token == THIS) {
@@ -1956,7 +1962,7 @@ self =>
Import(t, List(ImportSelector(name, nameOffset, name, nameOffset)))
}
}
- atPos(importOffset, start) { loop() }
+ atPos(start) { loop() }
}
/** ImportSelectors ::= `{' {ImportSelector `,'} (ImportSelector | `_') `}'