Currently, enabling a logger requires modifying https://github.com/lampepfl/dotty/blob/61cba970fec1017223ceb37da05f241f011c14d4/compiler/src/dotty/tools/dotc/config/Printers.scala, replacing say val exhaustivity: Printer = noPrinter with val exhaustivity: Printer = default.
This is neither documented nor convenient, and we can't ask users to enable it for bugs they struggle minimizing. We should probably add a -Ylog: setting.
@Blaisorblade
There are two ways I can think of doing this:
Keep Printers an object, and turn every printer field (currently a val) into a def with an implicit Context argument (so we can access the new YlogPrinter flag (Ylog is already taken)).
Turn Printers into a trait and move it inside the cake for Context. This is more efficient because the printer fields can remain as vals, but maybe cakes are no longer hip?
Do you have a preference?
I think a hard requirement is that this feature should not introduce any overhead when no printer is enabled. So two things to keep in mind:
ContextBase. So you should not mix Printers with Context but with ContextBaseThere is already a -Ylog option that will print stuff without having to touch the Printers. IIUC the distinction between the two is intentional (for performance reason?), and the Printers logs are meant to be a debugging tool for compiler writers, no something that we want to exposed under a flag.
Most helpful comment
I think a hard requirement is that this feature should not introduce any overhead when no printer is enabled. So two things to keep in mind:
ContextBase. So you should not mixPrinterswithContextbut withContextBase