Skip to content

Commit d0c1887

Browse files
Add simplified toString on Positions which matches pickled data
1 parent d6b06a1 commit d0c1887

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
531531
else if (!tree.isDef) txt = ("<" ~ txt ~ ":" ~ toText(tp) ~ ">").close
532532
}
533533
if (ctx.settings.Yprintpos.value && !tree.isInstanceOf[WithoutTypeOrPos[_]])
534-
txt = txt ~ "@" ~ tree.pos.toString
534+
txt = txt ~ "@" ~ tree.pos.toString(simplified = true)
535535
tree match {
536536
case Block(_, _) | Template(_, _, _, _) => txt
537537
case _ => txt.close

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,12 @@ object Positions {
108108
/** A synthetic copy of this position */
109109
def toSynthetic = if (isSynthetic) this else Position(start, end)
110110

111-
override def toString = {
112-
val (left, right) = if (isSynthetic) ("<", ">") else ("[", "]")
111+
override def toString: String = toString(simplified = false)
112+
113+
def toString(simplified: Boolean): String = {
114+
val (left, right) = if (simplified || isSynthetic) ("<", ">") else ("[", "]")
113115
if (exists)
114-
s"$left$start..${if (point == start) "" else s"$point.."}$end$right"
116+
s"$left$start..${if (simplified || point == start) "" else s"$point.."}$end$right"
115117
else
116118
s"${left}no position${right}"
117119
}

0 commit comments

Comments
 (0)