Skip to content

Commit ca096d9

Browse files
committed
New debug option: -Yshow-tree-ids
When enabled, we print trees with their uniqueIds. This was useful in diagnosing the issue, because that way we could find out when a tree that was missing in one version was created in the other.
1 parent 760f631 commit ca096d9

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ScalaSettings extends Settings.SettingGroup {
9999
val YdumpSbtInc = BooleanSetting("-Ydump-sbt-inc", "For every compiled foo.scala, output the API representation and dependencies used for sbt incremental compilation in foo.inc, implies -Yforce-sbt-phases.")
100100
val YcheckAllPatmat = BooleanSetting("-Ycheck-all-patmat", "Check exhaustivity and redundancy of all pattern matching (used for testing the algorithm)")
101101
val YretainTrees = BooleanSetting("-Yretain-trees", "Retain trees for top-level classes, accessible from ClassSymbol#tree")
102+
val YshowTreeIds = BooleanSetting("-Yshow-tree-ids", "Uniquely tag all tree nodes in debugging output.")
102103

103104
/** Area-specific debug output */
104105
val Yexplainlowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
617617
val clsStr = ""//if (tree.isType) tree.getClass.toString else ""
618618
txt = (txt ~ "@" ~ pos.toString ~ clsStr).close
619619
}
620+
if (ctx.settings.YshowTreeIds.value)
621+
txt = (txt ~ "#" ~ tree.uniqueId.toString).close
620622
tree match {
621623
case Block(_, _) | Template(_, _, _, _) => txt
622624
case _ => txt.close

0 commit comments

Comments
 (0)