Skip to content

Commit 9bec5b2

Browse files
committed
Ignore -YprintUser after first transform
1 parent 0f3ee9c commit 9bec5b2

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class ScalaSettings extends Settings.SettingGroup {
6060
val XprintTypes = BooleanSetting("-Xprint-types", "Print tree types (debugging option).")
6161
val XprintDiff = BooleanSetting("-Xprint-diff", "Print changed parts of the tree since last print.")
6262
val XprintDiffDel = BooleanSetting("-Xprint-diff-del", "Print chaged parts of the tree since last print including deleted parts.")
63-
val XprintUser = BooleanSetting("-Xprint-user", "Print the program using user friendly abstractions.")
6463
val Xprompt = BooleanSetting("-Xprompt", "Display a prompt after each error (debugging option).")
6564
val XmainClass = StringSetting("-Xmain-class", "path", "Class for manifest's Main-Class entry (only useful with -d <jar>)", "")
6665
val XnoValueClasses = BooleanSetting("-Xno-value-classes", "Do not use value classes. Helps debugging.")
@@ -103,6 +102,7 @@ class ScalaSettings extends Settings.SettingGroup {
103102
val YplainPrinter = BooleanSetting("-Yplain-printer", "Pretty-print using a plain printer.")
104103
val YprintSyms = BooleanSetting("-Yprint-syms", "when printing trees print info in symbols instead of corresponding info in trees.")
105104
val YprintDebug = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.")
105+
val YprintUser = BooleanSetting("-Yprint-user", "Print the program using user friendly abstractions.")
106106
val YshowPrintErrors = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.")
107107
val YtestPickler = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler")
108108
val YcheckReentrant = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.")

compiler/src/dotty/tools/dotc/decompiler/Main.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ object Main extends dotc.Driver {
1616
override def setup(args0: Array[String], rootCtx: Context): (List[String], Context) = {
1717
var args = args0.filter(a => a != "-decompile")
1818
args = if (args.contains("-from-tasty")) args else "-from-tasty" +: args
19-
super.setup("-Xprint-user" +: args, rootCtx)
19+
super.setup("-Yprint-user" +: args, rootCtx)
2020
}
2121
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import TypeApplications._
1414
import Decorators._
1515
import config.Config
1616
import util.Positions._
17-
import transform.SymUtils._
17+
import dotty.tools.dotc.transform.SymUtils._
18+
import dotty.tools.dotc.transform.FirstTransform
1819
import scala.annotation.switch
1920
import language.implicitConversions
2021
import dotty.tools.dotc.util.SourcePosition
@@ -27,6 +28,8 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
2728
private[this] var myCtx: Context = _ctx
2829
private[this] var printPos = ctx.settings.YprintPos.value
2930
private[this] val printLines = ctx.settings.printLines.value
31+
private[this] val YprintUser =
32+
ctx.settings.YprintUser.value && !ctx.phases.dropWhile(!_.isInstanceOf[FirstTransform]).contains(ctx.phase)
3033
override protected[this] implicit def ctx: Context = myCtx
3134

3235
def withEnclosingDef(enclDef: Tree[_ >: Untyped])(op: => Text): Text = {
@@ -416,7 +419,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
416419
}
417420
case Closure(env, ref, target) =>
418421
("closure(" ~ (toTextGlobal(env, ", ") ~ " | " provided env.nonEmpty) ~
419-
toTextGlobal(ref) ~ (":" ~ toText(target) provided !target.isEmpty) ~ ")").provided(!ctx.settings.XprintUser.value)
422+
toTextGlobal(ref) ~ (":" ~ toText(target) provided !target.isEmpty) ~ ")").provided(!YprintUser)
420423
case Match(sel, cases) =>
421424
if (sel.isEmpty) blockText(cases)
422425
else changePrec(GlobalPrec) { toText(sel) ~ keywordStr(" match ") ~ blockText(cases) }
@@ -480,7 +483,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
480483
}
481484
case tree @ DefDef(name, tparams, vparamss, tpt, _) =>
482485
dclTextOr {
483-
val printLambda = tree.symbol.isAnonymousFunction && ctx.settings.XprintUser.value
486+
val printLambda = tree.symbol.isAnonymousFunction && YprintUser
484487
val prefix = modText(tree.mods, keywordStr("def")) ~~ valDefText(nameIdText(tree)) provided (!printLambda)
485488
withEnclosingDef(tree) {
486489
addVparamssText(prefix ~ tparamsText(tparams), vparamss) ~ optAscription(tpt).provided(!printLambda) ~

0 commit comments

Comments
 (0)