diff options
author | liu fengyun <liu@fengy.me> | 2017-02-01 09:52:15 +0100 |
---|---|---|
committer | liu fengyun <liu@fengy.me> | 2017-02-02 10:26:37 +0100 |
commit | 485df22dcceb36c3970f2e39d0778d137148f65b (patch) | |
tree | e6a9dac159efa972d8c01499c2050a69d3882ee0 /compiler/src/dotty/tools/dotc | |
parent | af7fdb32df34b352bf39f01a26653b169e0d55cf (diff) | |
download | dotty-485df22dcceb36c3970f2e39d0778d137148f65b.tar.gz dotty-485df22dcceb36c3970f2e39d0778d137148f65b.tar.bz2 dotty-485df22dcceb36c3970f2e39d0778d137148f65b.zip |
fix #1626: inconsistent names in -Xprint
Diffstat (limited to 'compiler/src/dotty/tools/dotc')
-rw-r--r-- | compiler/src/dotty/tools/dotc/Run.scala | 3 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/printing/package.scala | 6 |
3 files changed, 9 insertions, 2 deletions
diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 0f652ff0b..38bf80bad 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -15,6 +15,7 @@ import reporting.Reporter import transform.TreeChecker import rewrite.Rewrites import java.io.{BufferedWriter, OutputStreamWriter} +import printing.XprintMode import scala.annotation.tailrec import scala.reflect.io.VirtualFile @@ -95,7 +96,7 @@ class Run(comp: Compiler)(implicit ctx: Context) { val unit = ctx.compilationUnit val prevPhase = ctx.phase.prev // can be a mini-phase val squashedPhase = ctx.squashed(prevPhase) - val treeString = unit.tpdTree.show + val treeString = unit.tpdTree.show(ctx.withProperty(XprintMode, Some(()))) ctx.echo(s"result of $unit after $squashedPhase:") diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 3085ad8fd..7f124563d 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -61,7 +61,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { override def nameString(name: Name): String = name.decode.toString override protected def simpleNameString(sym: Symbol): String = { - val name = sym.originalName + val name = if (ctx.property(XprintMode).isEmpty) sym.originalName else sym.name nameString(if (sym is ExpandedTypeParam) name.asTypeName.unexpandedName else name) } diff --git a/compiler/src/dotty/tools/dotc/printing/package.scala b/compiler/src/dotty/tools/dotc/printing/package.scala index 814eb2ad0..e2c0dda1b 100644 --- a/compiler/src/dotty/tools/dotc/printing/package.scala +++ b/compiler/src/dotty/tools/dotc/printing/package.scala @@ -2,6 +2,7 @@ package dotty.tools.dotc import core.StdNames.nme import parsing.{precedence, minPrec, maxPrec, minInfixPrec} +import util.Property.Key package object printing { @@ -14,4 +15,9 @@ package object printing { val GlobalPrec = parsing.minPrec val TopLevelPrec = parsing.minPrec - 1 + /** A property to indicate whether the compiler is currently doing -Xprint + * + * -Xprint will print `sym.name` instead of `sym.originalName` + */ + val XprintMode = new Key[Unit] } |