Skip to content

Commit

Permalink
Omit this-prefix when printing parameter references
Browse files Browse the repository at this point in the history
Print a reference to a parameter with just the name (e.g. "A") instead
of "C.this.A".
  • Loading branch information
odersky committed Dec 29, 2017
1 parent aa7ee91 commit f653095
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case tp: TypeRef =>
if (tp.symbol.isAnonymousClass && !ctx.settings.uniqid.value)
return toText(tp.info)
if (tp.symbol.is(Param))
tp.prefix match {
case pre: ThisType if pre.cls == tp.symbol.owner =>
return nameString(tp.symbol)
case _ =>
}
case ExprType(result) =>
return "=> " ~ toText(result)
case ErasedValueType(tycon, underlying) =>
Expand Down Expand Up @@ -501,7 +507,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
typeDefText(tparamsTxt, toText(rhs))
case LambdaTypeTree(tparams, body) =>
recur(body, tparamsText(tparams))
case rhs: TypeTree if rhs.tpe.isInstanceOf[TypeBounds] =>
case rhs: TypeTree if rhs.typeOpt.isInstanceOf[TypeBounds] =>
typeDefText(tparamsTxt, toText(rhs))
case rhs =>
typeDefText(tparamsTxt, optText(rhs)(" = " ~ _))
Expand Down

0 comments on commit f653095

Please sign in to comment.