Skip to content

Cyclic Error with separate compilation #9355

Closed
@michelou

Description

@michelou

Minimized code

Given the following two Scala source files (located in separate directories) :

// src\main\scala\Main.scala
object JSON {
  sealed trait Json
  final case class JArray(elems: JValue*) extends Json
  type JValue = Number | JArray
}

object Main extends App {
  println(JSON.JArray(1))
}
// src\test\scala\MainTest.scala
object MainTest extends App {
  println(JSON.JArray(1))
}

Output

Compilation (and execution) of Main.scala works as expected; (separate) compilation of MainTest.scala fails.

$ dotc -version
Dotty compiler version 0.26.0-bin-20200710-a162b7b-NIGHTLY-git-a162b7b -- Copyright 2002-2020, LAMP/EPFL

$ mkdir target\classes target\test-classes

$ dotc -d target\classes src\main\scala\Main.scala

$ dotr -cp target\classes Main
JArray(ArraySeq(1))

$ dotc -classpath target\classes -d target\test-classes src\test\scala\MainTest.scala
-- [E046] Cyclic Error: src\test\scala\MainTest.scala:2:15 ---------------------
2 |  println(JSON.JArray(1))
  |               ^
  |               Cyclic reference involving trait Seq

longer explanation available when compiling with `-explain`
1 error found

NB. Java SDK is jdk-1.8.0_252-b09. The same error occurs with previous versions of Dotty (e.g. 0.25.0-RC2 or 0.24.0-RC1).

Expectation

Separate compilation succeeds (and Main and MainTest print the same result).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions