Skip to content

Commit f653095

Browse files
committed
Omit this-prefix when printing parameter references
Print a reference to a parameter with just the name (e.g. "A") instead of "C.this.A".
1 parent aa7ee91 commit f653095

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
170170
case tp: TypeRef =>
171171
if (tp.symbol.isAnonymousClass && !ctx.settings.uniqid.value)
172172
return toText(tp.info)
173+
if (tp.symbol.is(Param))
174+
tp.prefix match {
175+
case pre: ThisType if pre.cls == tp.symbol.owner =>
176+
return nameString(tp.symbol)
177+
case _ =>
178+
}
173179
case ExprType(result) =>
174180
return "=> " ~ toText(result)
175181
case ErasedValueType(tycon, underlying) =>
@@ -501,7 +507,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
501507
typeDefText(tparamsTxt, toText(rhs))
502508
case LambdaTypeTree(tparams, body) =>
503509
recur(body, tparamsText(tparams))
504-
case rhs: TypeTree if rhs.tpe.isInstanceOf[TypeBounds] =>
510+
case rhs: TypeTree if rhs.typeOpt.isInstanceOf[TypeBounds] =>
505511
typeDefText(tparamsTxt, toText(rhs))
506512
case rhs =>
507513
typeDefText(tparamsTxt, optText(rhs)(" = " ~ _))

0 commit comments

Comments
 (0)