Skip to content

Commit 83610bb

Browse files
committed
Alternative fix
1 parent ad04880 commit 83610bb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1975,11 +1975,24 @@ object Parsers {
19751975
/** ImportSelector ::= id [`=>' id | `=>' `_']
19761976
*/
19771977
def importSelector(): Tree = {
1978+
val start = in.offset
19781979
val from = termIdentOrWildcard()
19791980
if (from.name != nme.WILDCARD && in.token == ARROW)
19801981
atPos(startOffset(from), in.skipToken()) {
1981-
Thicket(from, termIdentOrWildcard())
1982+
val start2 = in.offset
1983+
val to = termIdentOrWildcard()
1984+
val toWithPos =
1985+
if (to.name == nme.ERROR)
1986+
// error identifiers don't consume any characters, so atPos(start)(id) wouldn't set a position.
1987+
// Some testcases would then fail in Positioned.checkPos. Set a position anyway!
1988+
atPos(start2, start2, in.lastOffset)(to)
1989+
else
1990+
to
1991+
Thicket(from, toWithPos)
19821992
}
1993+
else if (from.name == nme.ERROR) {
1994+
atPos(start, start, in.lastOffset)(from)
1995+
}
19831996
else from
19841997
}
19851998

0 commit comments

Comments
 (0)