summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala12
-rw-r--r--test/files/positions/Overlap7.scala3
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