diff options
author | odersky <odersky@gmail.com> | 2017-04-11 11:49:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-11 11:49:40 +0200 |
commit | 579571e05a08120133173933e7eaf2555846d1d7 (patch) | |
tree | 7b0c89291126e89a901a8ab1230f874e26e25515 /compiler/src/dotty/tools/dotc/printing | |
parent | 4ff656138a2e4e127b763adeee3f0f72d515f6b6 (diff) | |
parent | 87608bded1fb23519a829fa7f6ee14d4b6a515dc (diff) | |
download | dotty-579571e05a08120133173933e7eaf2555846d1d7.tar.gz dotty-579571e05a08120133173933e7eaf2555846d1d7.tar.bz2 dotty-579571e05a08120133173933e7eaf2555846d1d7.zip |
Merge pull request #2128 from dotty-staging/add-semantic-names
Delay name mangling
Diffstat (limited to 'compiler/src/dotty/tools/dotc/printing')
3 files changed, 12 insertions, 14 deletions
diff --git a/compiler/src/dotty/tools/dotc/printing/Formatting.scala b/compiler/src/dotty/tools/dotc/printing/Formatting.scala index aa25880c2..b35a07027 100644 --- a/compiler/src/dotty/tools/dotc/printing/Formatting.scala +++ b/compiler/src/dotty/tools/dotc/printing/Formatting.scala @@ -139,7 +139,7 @@ object Formatting { seen.record(super.ParamRefNameString(param), param) override def toTextRef(tp: SingletonType): Text = tp match { - case tp: SkolemType => seen.record(tp.repr, tp) + case tp: SkolemType => seen.record(tp.repr.toString, tp) case _ => super.toTextRef(tp) } } diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index c762bbeaf..375edc3cb 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -97,11 +97,7 @@ class PlainPrinter(_ctx: Context) extends Printer { || (sym.name == nme.PACKAGE) // package ) - def nameString(name: Name): String = name.toString + { - if (ctx.settings.debugNames.value) - if (name.isTypeName) "/T" else "/V" - else "" - } + def nameString(name: Name): String = name.toString def toText(name: Name): Text = Str(nameString(name)) @@ -135,8 +131,7 @@ class PlainPrinter(_ctx: Context) extends Printer { toTextRHS(tp) case tp: TermRef if !tp.denotationIsCurrent && !homogenizedView || // always print underlying when testing picklers - tp.symbol.is(Module) || - tp.symbol.name.isImportName => + tp.symbol.is(Module) || tp.symbol.name == nme.IMPORT => toTextRef(tp) ~ ".type" case tp: TermRef if tp.denot.isOverloaded => "<overloaded " ~ toTextRef(tp) ~ ">" @@ -268,7 +263,7 @@ class PlainPrinter(_ctx: Context) extends Printer { if (idx >= 0) selfRecName(idx + 1) else "{...}.this" // TODO move underlying type to an addendum, e.g. ... z3 ... where z3: ... case tp: SkolemType => - if (homogenizedView) toText(tp.info) else tp.repr + if (homogenizedView) toText(tp.info) else toText(tp.repr) } } diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 0b683d90c..c3f36cc46 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -13,6 +13,7 @@ import Trees._ import TypeApplications._ import Decorators._ import config.Config +import transform.SymUtils._ import scala.annotation.switch import language.implicitConversions @@ -58,11 +59,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { protected val PrintableFlags = (SourceModifierFlags | Label | Module | Local).toCommonFlags - override def nameString(name: Name): String = name.decode.toString + override def nameString(name: Name): String = + if (ctx.settings.debugNames.value) name.debugString else name.decode.toString override protected def simpleNameString(sym: Symbol): String = { val name = if (ctx.property(XprintMode).isEmpty) sym.originalName else sym.name - nameString(if (sym is ExpandedTypeParam) name.asTypeName.unexpandedName else name) + nameString(if (sym.is(TypeParam)) name.asTypeName.unexpandedName else name) } override def fullNameString(sym: Symbol): String = @@ -130,7 +132,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { if (defn.isTupleClass(cls)) return toTextTuple(args) return (toTextLocal(tycon) ~ "[" ~ Text(args map argText, ", ") ~ "]").close case tp: TypeRef => - val hideType = !ctx.settings.debugAlias.value && (tp.symbol is AliasPreferred) + val hideType = !ctx.settings.debugAlias.value && (tp.symbol.isAliasPreferred) if (hideType && !ctx.phase.erasedTypes && !tp.symbol.isCompleting) { tp.info match { case TypeAlias(alias) => return toText(alias) @@ -154,8 +156,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { // one version of the annotation tree that has the correct positions). withoutPos(super.toText(tp)) case tp: SelectionProto => - return "?{ " ~ toText(tp.name) ~ (" " provided !tp.name.decode.last.isLetterOrDigit) ~ - ": " ~ toText(tp.memberProto) ~ " }" + return "?{ " ~ toText(tp.name) ~ + (" " provided !tp.name.toSimpleName.decode.last.isLetterOrDigit) ~ + ": " ~ toText(tp.memberProto) ~ " }" case tp: ViewProto => return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType) case tp @ FunProto(args, resultType, _) => |