From d5db550397216add31536905e7ca8ec93b28f38c Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 9 Sep 2022 11:09:12 +0200 Subject: [PATCH] Fix crash in -Vprofile code Fixes #16003 --- compiler/src/dotty/tools/dotc/reporting/Profile.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/Profile.scala b/compiler/src/dotty/tools/dotc/reporting/Profile.scala index 2cd67c87f386..6e2f83364dbe 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Profile.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Profile.scala @@ -103,7 +103,7 @@ class ActiveProfile(details: Int) extends Profile: name, info.lineCount, info.tokenCount, Profile.chunks(info.tastySize), s"${"%6.2f".format(complexity)} $explanation", path)) - def safeMax(xs: Array[Int]) = xs.max.max(10).min(50) + def safeMax(xs: Array[Int]) = if xs.isEmpty then 10 else xs.max.max(10).min(50) def printAndAggregateSourceInfos(): Profile.Info = val sourceNameWidth = safeMax(units.map(_.source.file.name.length))