Skip to content

Commit ca7617d

Browse files
authored
Merge pull request #7202 from dotty-staging/use-inline-and-inline-if
Use inline and inline-if to ensure constant folding happened
2 parents fba8e4f + cb6c873 commit ca7617d

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,47 +25,40 @@ object trace extends TraceSyntax {
2525
abstract class TraceSyntax {
2626
val isForced: Boolean
2727

28-
@forceInline
29-
def onDebug[TD](question: => String)(op: => TD)(implicit ctx: Context): TD =
28+
inline def onDebug[TD](question: => String)(op: => TD)(implicit ctx: Context): TD =
3029
conditionally(ctx.settings.YdebugTrace.value, question, false)(op)
3130

32-
@forceInline
33-
def conditionally[TC](cond: Boolean, question: => String, show: Boolean)(op: => TC)(implicit ctx: Context): TC =
34-
if (isForced || Config.tracingEnabled) {
31+
inline def conditionally[TC](cond: Boolean, question: => String, show: Boolean)(op: => TC)(implicit ctx: Context): TC =
32+
inline if (isForced || Config.tracingEnabled) {
3533
def op1 = op
3634
if (cond) apply[TC](question, Printers.default, show)(op1)
3735
else op1
3836
}
3937
else op
4038

41-
@forceInline
42-
def apply[T](question: => String, printer: Printers.Printer, showOp: Any => String)(op: => T)(implicit ctx: Context): T =
43-
if (isForced || Config.tracingEnabled) {
39+
inline def apply[T](question: => String, printer: Printers.Printer, showOp: Any => String)(op: => T)(implicit ctx: Context): T =
40+
inline if (isForced || Config.tracingEnabled) {
4441
def op1 = op
4542
if (!isForced && printer.eq(config.Printers.noPrinter)) op1
4643
else doTrace[T](question, printer, showOp)(op1)
4744
}
4845
else op
4946

50-
@forceInline
51-
def apply[T](question: => String, printer: Printers.Printer, show: Boolean)(op: => T)(implicit ctx: Context): T =
52-
if (isForced || Config.tracingEnabled) {
47+
inline def apply[T](question: => String, printer: Printers.Printer, show: Boolean)(op: => T)(implicit ctx: Context): T =
48+
inline if (isForced || Config.tracingEnabled) {
5349
def op1 = op
5450
if (!isForced && printer.eq(config.Printers.noPrinter)) op1
5551
else doTrace[T](question, printer, if (show) showShowable(_) else alwaysToString)(op1)
5652
}
5753
else op
5854

59-
@forceInline
60-
def apply[T](question: => String, printer: Printers.Printer)(op: => T)(implicit ctx: Context): T =
55+
inline def apply[T](question: => String, printer: Printers.Printer)(op: => T)(implicit ctx: Context): T =
6156
apply[T](question, printer, false)(op)
6257

63-
@forceInline
64-
def apply[T](question: => String, show: Boolean)(op: => T)(implicit ctx: Context): T =
58+
inline def apply[T](question: => String, show: Boolean)(op: => T)(implicit ctx: Context): T =
6559
apply[T](question, Printers.default, show)(op)
6660

67-
@forceInline
68-
def apply[T](question: => String)(op: => T)(implicit ctx: Context): T =
61+
inline def apply[T](question: => String)(op: => T)(implicit ctx: Context): T =
6962
apply[T](question, Printers.default, false)(op)
7063

7164
private def showShowable(x: Any)(implicit ctx: Context) = x match {

0 commit comments

Comments
 (0)