Skip to content

Commit 9b6e0ab

Browse files
committed
Merge pull request #426 from smarter/fix/positionCoord
Make implicit conversion from Position to Coord work for NoPosition
2 parents c679218 + 658eb4b commit 9b6e0ab

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/dotty/tools/dotc/util/Positions.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ object Positions {
164164

165165
/** An index coordinate */
166166
implicit def indexCoord(n: Int): Coord = new Coord(n + 1)
167-
implicit def positionCoord(pos: Position): Coord = new Coord(-(pos.point + 1))
167+
implicit def positionCoord(pos: Position): Coord =
168+
if (pos.exists) new Coord(-(pos.point + 1))
169+
else NoCoord
168170

169171
/** A sentinel for a missing coordinate */
170172
val NoCoord = new Coord(0)

0 commit comments

Comments
 (0)