Skip to content

Commit 036546f

Browse files
committed
Implement -Ydebug-pos
When set, prints full source positions, not just file + line.
1 parent c03e31b commit 036546f

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class ScalaSettings extends Settings.SettingGroup {
8787
val YdebugFlags: Setting[Boolean] = BooleanSetting("-Ydebug-flags", "Print all flags of definitions")
8888
val YdebugMissingRefs: Setting[Boolean] = BooleanSetting("-Ydebug-missing-refs", "Print a stacktrace when a required symbol is missing")
8989
val YdebugNames: Setting[Boolean] = BooleanSetting("-Ydebug-names", "Show internal representation of names")
90+
val YdebugPos: Setting[Boolean] = BooleanSetting("-Ydebug-pos", "Show full source positions including spans")
9091
val YtermConflict: Setting[String] = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error")
9192
val Ylog: Setting[List[String]] = PhasesSetting("-Ylog", "Log operations during")
9293
val YemitTastyInClass: Setting[Boolean] = BooleanSetting("-Yemit-tasty-in-class", "Generate tasty in the .class file and add an empty *.hasTasty file.")

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
4242

4343
/** If true, tweak output so it is the same before and after pickling */
4444
protected def homogenizedView: Boolean = ctx.settings.YtestPickler.value
45+
protected def debugPos: Boolean = ctx.settings.YdebugPos.value
4546

4647
def homogenize(tp: Type): Type =
4748
if (homogenizedView)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
604604
if (!suppressPositions) {
605605
if (printPos) {
606606
val posStr =
607-
if (homogenizedView)
607+
if (homogenizedView || debugPos)
608608
if (tree.isInstanceOf[MemberDef]) Str(s"${tree.source}${tree.span}")
609609
else Str(s"${tree.source}${tree.span.toSynthetic}")
610610
else

0 commit comments

Comments
 (0)