Skip to content

Commit 7864f4d

Browse files
committed
Cleanup code according to review
1 parent 37d0edd commit 7864f4d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

compiler/src/dotty/tools/dotc/reporting/trace.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import config.Printers
88
import core.Mode
99

1010
object trace extends TraceSyntax:
11-
inline def isForced: false = false
12-
protected val doForceTrace = isForced
11+
inline def isEnabled = Config.tracingEnabled
12+
protected val isForced = false
1313

1414
object force extends TraceSyntax:
15-
inline def isForced: true = true
16-
protected val doForceTrace = isForced
15+
inline def isEnabled: true = true
16+
protected val isForced = true
1717
end trace
1818

1919
/** This module is carefully optimized to give zero overhead if Config.tracingEnabled
@@ -22,24 +22,24 @@ end trace
2222
*/
2323
trait TraceSyntax:
2424

25-
inline def isForced: Boolean
26-
protected val doForceTrace: Boolean
25+
inline def isEnabled: Boolean
26+
protected val isForced: Boolean
2727

2828
inline def onDebug[TD](inline question: String)(inline op: TD)(using Context): TD =
2929
conditionally(ctx.settings.YdebugTrace.value, question, false)(op)
3030

3131
inline def conditionally[TC](inline cond: Boolean, inline question: String, inline show: Boolean)(inline op: TC)(using Context): TC =
32-
inline if isForced || Config.tracingEnabled then
32+
inline if isEnabled then
3333
apply(question, if cond then Printers.default else Printers.noPrinter, show)(op)
3434
else op
3535

3636
inline def apply[T](inline question: String, inline printer: Printers.Printer, inline showOp: Any => String)(inline op: T)(using Context): T =
37-
inline if isForced || Config.tracingEnabled then
37+
inline if isEnabled then
3838
doTrace[T](question, printer, showOp)(op)
3939
else op
4040

4141
inline def apply[T](inline question: String, inline printer: Printers.Printer, inline show: Boolean)(inline op: T)(using Context): T =
42-
inline if isForced || Config.tracingEnabled then
42+
inline if isEnabled then
4343
doTrace[T](question, printer, if show then showShowable(_) else alwaysToString)(op)
4444
else op
4545

@@ -62,7 +62,7 @@ trait TraceSyntax:
6262
printer: Printers.Printer = Printers.default,
6363
showOp: Any => String = alwaysToString)
6464
(op: => T)(using Context): T =
65-
if ctx.mode.is(Mode.Printing) || !doForceTrace && (printer eq Printers.noPrinter) then op
65+
if ctx.mode.is(Mode.Printing) || !isForced && (printer eq Printers.noPrinter) then op
6666
else
6767
// Avoid evaluating question multiple time, since each evaluation
6868
// may cause some extra logging output.
@@ -73,7 +73,7 @@ trait TraceSyntax:
7373
var logctx = ctx
7474
while logctx.reporter.isInstanceOf[StoreReporter] do logctx = logctx.outer
7575
def margin = ctx.base.indentTab * ctx.base.indent
76-
def doLog(s: String) = if doForceTrace then println(s) else report.log(s)
76+
def doLog(s: String) = if isForced then println(s) else report.log(s)
7777
def finalize(result: Any, note: String) =
7878
if !finalized then
7979
ctx.base.indent -= 1

0 commit comments

Comments
 (0)