Skip to content

Commit 529346d

Browse files
committed
Handle printing of term paramrefs
These were not printed before, fell back to toString method.
1 parent 7294180 commit 529346d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
134134
case tp: TypeType =>
135135
toTextRHS(tp)
136136
case tp: TermRef
137-
if !tp.denotationIsCurrent && !homogenizedView || // always print underyling when testing picklers
137+
if !tp.denotationIsCurrent && !homogenizedView || // always print underlying when testing picklers
138138
tp.symbol.is(Module) ||
139139
tp.symbol.name.isImportName =>
140140
toTextRef(tp) ~ ".type"
@@ -183,7 +183,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
183183
toTextGlobal(tp.resultType)
184184
}
185185
case tp: TypeParamRef =>
186-
TypeParamRefNameString(tp) ~ lambdaHash(tp.binder)
186+
ParamRefNameString(tp) ~ lambdaHash(tp.binder)
187+
case tp: TermParamRef =>
188+
ParamRefNameString(tp) ~ ".type"
187189
case AnnotatedType(tpe, annot) =>
188190
toTextLocal(tpe) ~ " " ~ toText(annot)
189191
case HKApply(tycon, args) =>
@@ -206,10 +208,10 @@ class PlainPrinter(_ctx: Context) extends Printer {
206208
}
207209
}.close
208210

209-
protected def TypeParamRefNameString(name: TypeName): String = name.toString
211+
protected def ParamRefNameString(name: Name): String = name.toString
210212

211-
protected def TypeParamRefNameString(param: TypeParamRef): String =
212-
TypeParamRefNameString(param.binder.paramNames(param.paramNum))
213+
protected def ParamRefNameString(param: ParamRef): String =
214+
ParamRefNameString(param.binder.paramNames(param.paramNum))
213215

214216
/** The name of the symbol without a unique id. Under refined printing,
215217
* the decoded original name.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
604604
def optText[T >: Untyped](tree: List[Tree[T]])(encl: Text => Text): Text =
605605
if (tree.exists(!_.isEmpty)) encl(blockText(tree)) else ""
606606

607-
override protected def TypeParamRefNameString(name: TypeName): String =
607+
override protected def ParamRefNameString(name: Name): String =
608608
name.unexpandedName.toString
609609

610610
override protected def treatAsTypeParam(sym: Symbol): Boolean = sym is TypeParam

0 commit comments

Comments
 (0)