Skip to content

Commit 3475da3

Browse files
committed
Clean up printing of capture sets
1 parent aada0bd commit 3475da3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,14 @@ class PlainPrinter(_ctx: Context) extends Printer {
189189
(" <: " ~ toText(bound) provided !bound.isAny)
190190
}.close
191191
case CapturingType(parent, refs) =>
192-
if refs.isConst then
193-
if Config.printCaptureSetsAsPrefix then
194-
changePrec(GlobalPrec)("{" ~ Text(refs.elems.toList.map(toTextCaptureRef), ", ") ~ "} " ~ toText(parent))
195-
else
196-
changePrec(InfixPrec)(toText(parent) ~ " retains " ~ toText(refs.toRetainsTypeArg))
192+
if printDebug && !refs.isConst then
193+
s"$refs " ~ toText(parent)
194+
else if refs.elems.isEmpty then
195+
toText(parent)
196+
else if Config.printCaptureSetsAsPrefix then
197+
changePrec(GlobalPrec)("{" ~ Text(refs.elems.toList.map(toTextCaptureRef), ", ") ~ "} " ~ toText(parent))
197198
else
198-
s"$refs " ~ toText(parent) // ^^^ improve
199+
changePrec(InfixPrec)(toText(parent) ~ " retains " ~ toText(refs.toRetainsTypeArg))
199200
case tp: PreviousErrorType if ctx.settings.XprintTypes.value =>
200201
"<error>" // do not print previously reported error message because they may try to print this error type again recuresevely
201202
case tp: ErrorType =>

0 commit comments

Comments
 (0)