Skip to content

Commit a2ec372

Browse files
committed
Hide capture sets when the current unit is not capture checked
1 parent 7aca3c4 commit a2ec372

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,10 +242,12 @@ class PlainPrinter(_ctx: Context) extends Printer {
242242
val refsText = if showAsCap then rootSetText else toTextCaptureSet(refs)
243243
toTextCapturing(parent, refsText, boxText)
244244
case tp @ RetainingType(parent, refs) =>
245-
val refsText = refs match
246-
case ref :: Nil if ref.symbol == defn.captureRoot => rootSetText
247-
case _ => toTextRetainedElems(refs)
248-
toTextCapturing(parent, refsText, "") ~ Str("R").provided(printDebug)
245+
if ctx.compilationUnit.needsCaptureChecking then
246+
val refsText = refs match
247+
case ref :: Nil if ref.symbol == defn.captureRoot => rootSetText
248+
case _ => toTextRetainedElems(refs)
249+
toTextCapturing(parent, refsText, "") ~ Str("R").provided(printDebug)
250+
else toText(parent)
249251
case tp: PreviousErrorType if ctx.settings.XprintTypes.value =>
250252
"<error>" // do not print previously reported error message because they may try to print this error type again recuresevely
251253
case tp: ErrorType =>

0 commit comments

Comments
 (0)