Skip to content

Commit 9ebdac4

Browse files
committed
Improve handling of printing unique ids on debug
1 parent c58b23f commit 9ebdac4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class PlainPrinter(_ctx: Context) extends Printer {
2626

2727
protected def maxToTextRecursions: Int = 100
2828

29+
protected def showUniqueIds = ctx.settings.uniqid.value || Printer.debugPrintUnique
30+
2931
protected final def limiter: MessageLimiter = ctx.property(MessageLimiter).get
3032

3133
protected def controlled(op: => Text): Text = limiter.controlled(op)
@@ -248,14 +250,14 @@ class PlainPrinter(_ctx: Context) extends Printer {
248250

249251
/** If -uniqid is set, the hashcode of the lambda type, after a # */
250252
protected def lambdaHash(pt: LambdaType): Text =
251-
if (ctx.settings.uniqid.value)
253+
if (showUniqueIds)
252254
try "#" + pt.hashCode
253255
catch { case ex: NullPointerException => "" }
254256
else ""
255257

256258
/** If -uniqid is set, the unique id of symbol, after a # */
257259
protected def idString(sym: Symbol): String =
258-
if (ctx.settings.uniqid.value || Printer.debugPrintUnique) "#" + sym.id else ""
260+
if (showUniqueIds || Printer.debugPrintUnique) "#" + sym.id else ""
259261

260262
def nameString(sym: Symbol): String =
261263
simpleNameString(sym) + idString(sym) // + "<" + (if (sym.exists) sym.owner else "") + ">"

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
213213
case tp: RefinedType if defn.isFunctionType(tp) && !printDebug =>
214214
toTextDependentFunction(tp.refinedInfo.asInstanceOf[MethodType])
215215
case tp: TypeRef =>
216-
if (tp.symbol.isAnonymousClass && !ctx.settings.uniqid.value)
216+
if (tp.symbol.isAnonymousClass && !showUniqueIds)
217217
toText(tp.info)
218218
else if (tp.symbol.is(Param))
219219
tp.prefix match {
@@ -729,7 +729,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
729729
protected def optAscription[T >: Untyped](tpt: Tree[T]): Text = optText(tpt)(": " ~ _)
730730

731731
private def idText(tree: untpd.Tree): Text =
732-
if ((ctx.settings.uniqid.value || Printer.debugPrintUnique) && tree.hasType && tree.symbol.exists) s"#${tree.symbol.id}" else ""
732+
if showUniqueIds && tree.hasType && tree.symbol.exists then s"#${tree.symbol.id}" else ""
733733

734734
private def useSymbol(tree: untpd.Tree) =
735735
tree.hasType && tree.symbol.exists && ctx.settings.YprintSyms.value

0 commit comments

Comments
 (0)