Skip to content

Commit 3f0c6d3

Browse files
authored
Better output under -Ydetailed-stats (#15950)
- Don't print empty lines if Stats.enabled is false - Print constraint size
2 parents d5ac8e5 + 5c16d2c commit 3f0c6d3

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/src/dotty/tools/dotc/core/ConstraintRunInfo.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ trait ConstraintRunInfo { self: Run =>
1212
maxSize = size
1313
maxConstraint = c
1414
}
15-
def printMaxConstraint()(using Context): Unit = {
16-
val printer = if (ctx.settings.YdetailedStats.value) default else typr
17-
if (maxSize > 0) printer.println(s"max constraint = ${maxConstraint.nn.show}")
18-
}
15+
def printMaxConstraint()(using Context): Unit =
16+
if maxSize > 0 then
17+
val printer = if ctx.settings.YdetailedStats.value then default else typr
18+
printer.println(s"max constraint size: $maxSize")
19+
try printer.println(s"max constraint = ${maxConstraint.nn.show}")
20+
catch case ex: StackOverflowError => printer.println("max constraint cannot be printed due to stack overflow")
21+
1922
protected def reset(): Unit = maxConstraint = null
2023
}

compiler/src/dotty/tools/dotc/util/Stats.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import collection.mutable
5555
}
5656

5757
def maybeMonitored[T](op: => T)(using Context): T =
58-
if (ctx.settings.YdetailedStats.value) {
58+
if (ctx.settings.YdetailedStats.value && hits.nonEmpty) {
5959
monitored = true
6060
try op
6161
finally {

0 commit comments

Comments
 (0)