Skip to content

Commit 66c96a1

Browse files
Blaisorbladeallanrenucci
authored andcommitted
Alternative fix
1 parent 6182b2c commit 66c96a1

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
@@ -2015,11 +2015,24 @@ object Parsers {
20152015
/** ImportSelector ::= id [`=>' id | `=>' `_']
20162016
*/
20172017
def importSelector(): Tree = {
2018+
val start = in.offset
20182019
val from = termIdentOrWildcard()
20192020
if (from.name != nme.WILDCARD && in.token == ARROW)
20202021
atPos(startOffset(from), in.skipToken()) {
2021-
Thicket(from, termIdentOrWildcard())
2022+
val start2 = in.offset
2023+
val to = termIdentOrWildcard()
2024+
val toWithPos =
2025+
if (to.name == nme.ERROR)
2026+
// error identifiers don't consume any characters, so atPos(start)(id) wouldn't set a position.
2027+
// Some testcases would then fail in Positioned.checkPos. Set a position anyway!
2028+
atPos(start2, start2, in.lastOffset)(to)
2029+
else
2030+
to
2031+
Thicket(from, toWithPos)
20222032
}
2033+
else if (from.name == nme.ERROR) {
2034+
atPos(start, start, in.lastOffset)(from)
2035+
}
20232036
else from
20242037
}
20252038

0 commit comments

Comments
 (0)