Skip to content

Commit 07a9815

Browse files
committed
Refine error message: don't show code for whole object
1 parent 32f86d0 commit 07a9815

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ object Objects:
163163
val joinedTrace = data.pendingTraces.slice(index + 1, data.checkingObjects.size).foldLeft(pendingTrace) { (a, acc) => acc ++ a }
164164
val callTrace = Trace.buildStacktrace(joinedTrace, "Calling trace:\n")
165165
val cycle = data.checkingObjects.slice(index, data.checkingObjects.size)
166-
report.warning("Cyclic initialization: " + cycle.map(_.show).mkString(" -> ") + " -> " + clazz.show + ". " + callTrace, clazz.defTree)
166+
val pos = clazz.defTree.asInstanceOf[TypeDef].rhs.asInstanceOf[Template].constr
167+
report.warning("Cyclic initialization: " + cycle.map(_.show).mkString(" -> ") + " -> " + clazz.show + ". " + callTrace, pos)
167168
else if index == -1 && data.checkedObjects.indexOf(clazz) == -1 then
168169
data.pendingTraces += pendingTrace
169170
data.checkingObjects += clazz
@@ -527,7 +528,7 @@ object Objects:
527528
def iterate()(using Context): Unit =
528529
count += 1
529530

530-
given Trace = Trace.empty.add(classSym.defTree)
531+
given Trace = Trace.empty.add(tpl.constr)
531532
given env: Env.Data = Env.empty
532533

533534
log("Iteration " + count) {

0 commit comments

Comments
 (0)