diff options
author | Miles Sabin <miles@milessabin.com> | 2010-05-11 12:42:21 +0000 |
---|---|---|
committer | Miles Sabin <miles@milessabin.com> | 2010-05-11 12:42:21 +0000 |
commit | 582c53207bb7eda2cde2070db1ee42691dcfb33e (patch) | |
tree | bc6a28d379a062f3e7f31fbf6dbba292a4684494 | |
parent | 180c6d047dbe16d5a2d4ec9186aad749e64e012d (diff) | |
download | scala-582c53207bb7eda2cde2070db1ee42691dcfb33e.tar.gz scala-582c53207bb7eda2cde2070db1ee42691dcfb33e.tar.bz2 scala-582c53207bb7eda2cde2070db1ee42691dcfb33e.zip |
Fix from Mirko Stocker and unit test for #3416.
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 12 | ||||
-rw-r--r-- | test/files/positions/Overlap7.scala | 3 |
2 files changed, 12 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 | `_') `}' diff --git a/test/files/positions/Overlap7.scala b/test/files/positions/Overlap7.scala new file mode 100644 index 0000000000..b3dc0d10e2 --- /dev/null +++ b/test/files/positions/Overlap7.scala @@ -0,0 +1,3 @@ +import java.lang.String, java.lang.Object + +class Overlap7 |