Skip to content

Commit 535e4b2

Browse files
committed
Suppress trivial self cycle warning
1 parent 798f531 commit 535e4b2

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ object Objects:
158158
def checkCycle(clazz: ClassSymbol)(work: => Unit)(using data: Data, ctx: Context, pendingTrace: Trace) =
159159
val index = data.checkingObjects.indexOf(clazz)
160160

161-
if index != -1 && data.checkingObjects.size > 1 then
161+
if index != -1 && data.checkingObjects.size - 1 > index then
162162
val joinedTrace = data.pendingTraces.slice(index + 1, data.checkingObjects.size).foldLeft(pendingTrace) { (a, acc) => acc ++ a }
163163
val callTrace = Trace.buildStacktrace(joinedTrace, "Calling trace:\n")
164164
val cycle = data.checkingObjects.slice(index, data.checkingObjects.size)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object C:
2+
val n: Int = A.n
3+
4+
object A:
5+
val x: Int = 10
6+
val n: Int = B.foo()
7+
8+
object B:
9+
def foo(): Int = A.x

0 commit comments

Comments
 (0)