From 529346d241459f0d20e607fb5ea78b6091c8bc12 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 10 Apr 2017 16:14:50 +0200 Subject: Handle printing of term paramrefs These were not printed before, fell back to toString method. --- compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala | 12 +++++++----- compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala index d5014b547..c762bbeaf 100644 --- a/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala @@ -134,7 +134,7 @@ class PlainPrinter(_ctx: Context) extends Printer { case tp: TypeType => toTextRHS(tp) case tp: TermRef - if !tp.denotationIsCurrent && !homogenizedView || // always print underyling when testing picklers + if !tp.denotationIsCurrent && !homogenizedView || // always print underlying when testing picklers tp.symbol.is(Module) || tp.symbol.name.isImportName => toTextRef(tp) ~ ".type" @@ -183,7 +183,9 @@ class PlainPrinter(_ctx: Context) extends Printer { toTextGlobal(tp.resultType) } case tp: TypeParamRef => - TypeParamRefNameString(tp) ~ lambdaHash(tp.binder) + ParamRefNameString(tp) ~ lambdaHash(tp.binder) + case tp: TermParamRef => + ParamRefNameString(tp) ~ ".type" case AnnotatedType(tpe, annot) => toTextLocal(tpe) ~ " " ~ toText(annot) case HKApply(tycon, args) => @@ -206,10 +208,10 @@ class PlainPrinter(_ctx: Context) extends Printer { } }.close - protected def TypeParamRefNameString(name: TypeName): String = name.toString + protected def ParamRefNameString(name: Name): String = name.toString - protected def TypeParamRefNameString(param: TypeParamRef): String = - TypeParamRefNameString(param.binder.paramNames(param.paramNum)) + protected def ParamRefNameString(param: ParamRef): String = + ParamRefNameString(param.binder.paramNames(param.paramNum)) /** The name of the symbol without a unique id. Under refined printing, * the decoded original name. diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 76bce7920..0b683d90c 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -604,7 +604,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { def optText[T >: Untyped](tree: List[Tree[T]])(encl: Text => Text): Text = if (tree.exists(!_.isEmpty)) encl(blockText(tree)) else "" - override protected def TypeParamRefNameString(name: TypeName): String = + override protected def ParamRefNameString(name: Name): String = name.unexpandedName.toString override protected def treatAsTypeParam(sym: Symbol): Boolean = sym is TypeParam -- cgit v1.2.3