Skip to content

Commit 12372b8

Browse files
committed
Make 'namePos' return 'NoPosition' if name is 'nme.ERROR'
'namePos' used to return nonsensical position when the tree was malformed (e.g. "case class").
1 parent d97bce0 commit 12372b8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ object Trees {
337337
* a calling chain from `viewExists`), in that case the return position is NoPosition.
338338
*/
339339
def namePos =
340-
if (pos.exists)
340+
if (pos.exists && name.toTermName != nme.ERROR)
341341
if (rawMods.is(Synthetic)) Position(pos.point, pos.point)
342342
else Position(pos.point, pos.point + name.stripModuleClassSuffix.lastPart.length, pos.point)
343-
else pos
343+
else NoPosition
344344
}
345345

346346
/** A ValDef or DefDef tree */

0 commit comments

Comments
 (0)