File tree 2 files changed +6
-6
lines changed
compiler/src/dotty/tools/dotc/transform/init
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -146,15 +146,15 @@ class CycleChecker(cache: Cache) {
146
146
val obj = dep.symbol
147
147
if state.path.contains(obj) then
148
148
val cycle = state.path.dropWhile(_ != obj)
149
- val trace = state.trace.map(_.source) :+ dep.source
149
+ val trace = state.trace.dropWhile(_.symbol != obj). map(_.source) :+ dep.source
150
150
if cycle.size > 1 then
151
- CyclicObjectInit (obj , trace) :: Nil
151
+ CyclicObjectInit (cycle , trace) :: Nil
152
152
else
153
153
ObjectLeakDuringInit (obj, trace) :: Nil
154
154
else
155
155
val constr = obj.moduleClass.primaryConstructor
156
156
state.visitObject(dep) {
157
- check(StaticCall (constr.owner.asClass, constr)(constr .defTree))
157
+ check(StaticCall (constr.owner.asClass, constr)(obj.moduleClass .defTree))
158
158
}
159
159
}
160
160
Original file line number Diff line number Diff line change @@ -69,13 +69,13 @@ object Errors {
69
69
report.warning(show + stacktrace, field.srcPos)
70
70
}
71
71
72
- case class CyclicObjectInit (obj : Symbol , trace : Seq [Tree ]) extends Error {
72
+ case class CyclicObjectInit (objs : Seq [ Symbol ] , trace : Seq [Tree ]) extends Error {
73
73
def source : Tree = trace.last
74
74
def show (using Context ): String =
75
- " Cyclic object initialization of " + obj. show + " ."
75
+ " Cyclic object initialization for " + objs.map(_. show).mkString( " , " ) + " ."
76
76
77
77
override def issue (using Context ): Unit =
78
- report.warning(show + stacktrace, obj .srcPos)
78
+ report.warning(show + stacktrace, objs.head .srcPos)
79
79
}
80
80
81
81
case class ObjectLeakDuringInit (obj : Symbol , trace : Seq [Tree ]) extends Error {
You can’t perform that action at this time.
0 commit comments