diff --git a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala index 1050fbe85ef2..12a1ba3a0642 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -864,7 +864,7 @@ class Objects(using Context @constructorOnly): Bottom case Bottom => - if field.isStaticObject then ObjectRef(field.moduleClass.asClass) + if field.isStaticObject then accessObject(field.moduleClass.asClass) else Bottom case ValueSet(values) => diff --git a/tests/init-global/warn/cyclic-object.scala b/tests/init-global/warn/cyclic-object.scala new file mode 100644 index 000000000000..e997d3259877 --- /dev/null +++ b/tests/init-global/warn/cyclic-object.scala @@ -0,0 +1,9 @@ +package cyclicObject + +object O1 { // warn + val o = cyclicObject.O2 +} + +object O2 { + val o = cyclicObject.O1 +}