Skip to content

Commit 9adad25

Browse files
committed
Refine error messages
1 parent 4dc8b49 commit 9adad25

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

compiler/src/dotty/tools/dotc/transform/init/Errors.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Errors {
2424
def show(implicit ctx: Context): String
2525

2626
def report(implicit ctx: Context): Unit =
27-
ctx.warning(show + " Calling trace:\n" + stacktrace, source.sourcePos)
27+
ctx.warning(show + stacktrace, source.sourcePos)
2828

2929
def toErrors: Errors = Set(this)
3030

@@ -101,14 +101,16 @@ object Errors {
101101
case class UnsafePromotion(pot: Potential, source: Tree, trace: Vector[Tree], errors: Errors) extends Error {
102102
assert(errors.nonEmpty)
103103

104+
override def report(implicit ctx: Context): Unit = ctx.warning(show, source.sourcePos)
105+
104106
def show(implicit ctx: Context): String = {
105107
var index = 0
106108
"Promoting the value " + source.show + " to initialized is unsafe.\n" + stacktrace +
107-
"\n The unsafe promotion is caused by the following problem(s):" +
108-
errors.map { error =>
109+
"\nThe unsafe promotion may cause the following problem(s):\n" +
110+
(errors.flatMap(_.flatten).map { error =>
109111
index += 1
110-
s"\n $index" + error.show + error.stacktrace
111-
}.mkString
112+
s"\n$index. " + error.show + error.stacktrace
113+
}.mkString)
112114
}
113115
}
114116
}

0 commit comments

Comments
 (0)