Skip to content

Commit be073b1

Browse files
committed
Make printing capture sets dependent on -Ycc-debug
1 parent 9e5fc5f commit be073b1

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureSet.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,11 @@ object CaptureSet:
315315
deps.foreach(_.propagateSolved())
316316

317317
override def toText(printer: Printer): Text =
318+
def debug = inContext(printer.printerContext) {
319+
ctx.settings.YccDebug.value
320+
}
318321
super.toText(printer)
319-
~ (id.toString ~ getClass.getSimpleName.take(1) provided !isConst)
322+
~ (id.toString ~ getClass.getSimpleName.take(1) provided !isConst && debug)
320323

321324
override def toString = s"Var$id$elems"
322325
end Var

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import config.Config
1818
import cc.{CapturingType, CaptureSet}
1919

2020
class PlainPrinter(_ctx: Context) extends Printer {
21+
2122
/** The context of all public methods in Printer and subclasses.
2223
* Overridden in RefinedPrinter.
2324
*/
24-
protected def curCtx: Context = _ctx.addMode(Mode.Printing)
25-
protected given [DummyToEnforceDef]: Context = curCtx
25+
def printerContext: Context = _ctx.addMode(Mode.Printing)
26+
protected given [DummyToEnforceDef]: Context = printerContext
2627

2728
protected def printDebug = ctx.settings.YprintDebug.value
2829

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import core._
66
import Texts._, ast.Trees._
77
import Types.{Type, SingletonType, LambdaParam},
88
Symbols.Symbol, Scopes.Scope, Constants.Constant,
9-
Names.Name, Denotations._, Annotations.Annotation
9+
Names.Name, Denotations._, Annotations.Annotation, Contexts.Context
1010
import typer.Implicits.SearchResult
1111
import util.SourcePosition
1212
import typer.ImportInfo
@@ -185,6 +185,9 @@ abstract class Printer {
185185

186186
/** A plain printer without any embellishments */
187187
def plain: Printer
188+
189+
/** The context in which this printer operates */
190+
def printerContext: Context
188191
}
189192
object Printer {
190193

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
3434

3535
/** A stack of enclosing DefDef, TypeDef, or ClassDef, or ModuleDefs nodes */
3636
private var enclosingDef: untpd.Tree = untpd.EmptyTree
37-
private var myCtx: Context = super.curCtx
37+
private var myCtx: Context = super.printerContext
3838
private var printPos = ctx.settings.YprintPos.value
3939
private val printLines = ctx.settings.printLines.value
4040

41-
override protected def curCtx: Context = myCtx
41+
override def printerContext: Context = myCtx
4242

4343
def withEnclosingDef(enclDef: Tree[? >: Untyped])(op: => Text): Text = {
4444
val savedCtx = myCtx

0 commit comments

Comments
 (0)