From 582c53207bb7eda2cde2070db1ee42691dcfb33e Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Tue, 11 May 2010 12:42:21 +0000 Subject: Fix from Mirko Stocker and unit test for #3416. --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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 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 | `_') `}' -- cgit v1.2.3