Closed
Description
Minimized code
In file test.scala
:
package p
export X._
object X:
val A = 42
Output
[info] compiling 1 Scala source to /home/bjornr/tmp/bug-repl/target/scala-3.0.0-M3/classes ...
[error] -- [E046] Cyclic Error: /home/bjornr/tmp/bug-repl/src/main/scala/p/test.scala:2:7
[error] 2 |export X.A
[error] | ^
[error] | Cyclic reference involving module X
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
Expectation
Export on top level should work.
There is a work-around: put the export in another file test2.scala
and now both test.scala
and test2.scala
compiles:
package p
export X._
object Y {
val B = A
}
Note that A is now visible on top level without an import X._
in file test2.scala
, as expected.
Output with both files (but it shouldn't be necessary to put the export in another file...):
sbt:bug-repl> clean
[success] Total time: 0 s, completed Jan 17, 2021, 8:29:56 PM
sbt:bug-repl> console
[info] compiling 2 Scala sources to /home/bjornr/tmp/bug-repl/target/scala-3.0.0-M3/classes ...
scala> p.A
val res0: Int = 42