Skip to content

Cyclic reference involving val <import> errors still exist #26340

Closed

Description

@soronpo

This is a follow-up to #25894 (minimization inc_export_cyclic_err), which was fixed by #25900. The fix breaks the cycle when a single file is recompiled against its siblings' TASTy, but the same cyclic error still occurs when two source units are recompiled together.

#25900 force-completes only the sibling <src>$package classes that come from the classpath (isDefinedInBinary). Here a second source unit, hdl.scala, is recompiled at the same time and re-exports the same givens via a top-level export hdl.*. Because hdl is now a source sibling (not isDefinedInBinary), it is not force-completed, so the export chain through it is resolved lazily during the import's completer and the cycle returns.

Compiler version

3.9.0-RC1 (contains the fix from #25900 / #25894).

Minimized code

Self-contained reproduction (3 files, ~25 LOC):
https://github.com/soronpo/dottybug/tree/inc_export_cyclic_err_after_25900

DFVal.scala (loaded from TASTy in stage 2):

package dfhdl

object DFVal:
  export DFXInt.Ops.c1
  object Ops:
    type CarryOp

stubs.scala (recompiled):

package dfhdl
import DFVal.Ops.CarryOp

trait ExactOp2Aux[Op]

object DFDecimal:
  object Ops:
    export DFXInt.Ops.*

object DFXInt:
  object Ops:
    given c1: ExactOp2Aux[CarryOp] = ???

hdl.scala (recompiled together with stubs.scala):

package dfhdl
object hdl:
  export DFDecimal.Ops.*

export hdl.*

Pure scalac, two-stage separate compilation (no sbt/Zinc, no plugin, not
OS-specific):

# stage 1 — clean build, all files (succeeds)
scalac -d out1 *.scala
# stage 2 — recompile two units against stage 1 (cyclic error)
scalac -classpath out1 -d out2 stubs.scala hdl.scala

Output

-- [E046] Cyclic Error: stubs.scala:11:26
11 |    given c1: ExactOp2Aux[CarryOp] = ???
   |                          ^
   |                          Cyclic reference involving val <import>

The val <import> is import DFVal.Ops.CarryOp at the top of stubs.scala.

Expectation

No error.

Related

Activity

  1. added a commit that references this issue on Jul 8, 2026
    652f699
  2. added a commit that references this issue on Jul 8, 2026
    15f7d43
  3. added this to the 3.10.0 milestone on Aug 26, 2026
  4. added 2 commits that reference this issue on Oct 23, 2026
    833924c
    fcf41e3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions