Skip to content

Commit 5f0cc46

Browse files
committed
Change the printers to print erased function parameters
1 parent 0b976ff commit 5f0cc46

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,13 @@ class PlainPrinter(_ctx: Context) extends Printer {
297297
"(" ~ toTextRef(tp) ~ " : " ~ toTextGlobal(tp.underlying) ~ ")"
298298

299299
protected def paramsText(lam: LambdaType): Text = {
300-
def paramText(name: Name, tp: Type) =
301-
toText(name) ~ lambdaHash(lam) ~ toTextRHS(tp, isParameter = true)
302-
Text(lam.paramNames.lazyZip(lam.paramInfos).map(paramText), ", ")
300+
val companion = lam.companion
301+
val isErased = if companion.isInstanceOf[ErasedMethodCompanion] then
302+
companion.asInstanceOf[ErasedMethodCompanion].isErased
303+
else List.fill(lam.paramNames.length)(false)
304+
def paramText(name: Name, tp: Type, erased: Boolean) =
305+
keywordText("erased ").provided(erased) ~ toText(name) ~ lambdaHash(lam) ~ toTextRHS(tp, isParameter = true)
306+
Text(lam.paramNames.lazyZip(lam.paramInfos).lazyZip(isErased).map(paramText), ", ")
303307
}
304308

305309
protected def ParamRefNameString(name: Name): String = nameString(name)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
166166
case info: MethodType =>
167167
changePrec(GlobalPrec) {
168168
"("
169-
~ keywordText("erased ").provided(info.isErasedMethod)
170169
~ paramsText(info)
171170
~ ") "
172171
~ arrow(info.isImplicitMethod, isPure)
@@ -868,7 +867,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
868867
"()"
869868
case untpd.ValDefs(vparams @ (vparam :: _)) =>
870869
"(" ~ keywordText("using ").provided(vparam.mods.is(Given))
871-
~ keywordText("erased ").provided(vparam.mods.is(Erased))
872870
~ toText(vparams, ", ") ~ ")"
873871
case untpd.TypeDefs(tparams) =>
874872
"[" ~ toText(tparams, ", ") ~ "]"
@@ -879,6 +877,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
879877
protected def valDefToText[T <: Untyped](tree: ValDef[T]): Text = {
880878
dclTextOr(tree) {
881879
modText(tree.mods, tree.symbol, keywordStr(if (tree.mods.is(Mutable)) "var" else "val"), isType = false) ~~
880+
keywordText("erased ").provided(tree.mods.flags.is(Flags.Erased)) ~
882881
valDefText(nameIdText(tree)) ~ optAscription(tree.tpt) ~
883882
withEnclosingDef(tree) { optText(tree.rhs)(" = " ~ _) }
884883
}

0 commit comments

Comments
 (0)