Skip to content

Cyclic Error with separate compilation #9355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michelou opened this issue Jul 12, 2020 · 2 comments · Fixed by #10962
Closed

Cyclic Error with separate compilation #9355

michelou opened this issue Jul 12, 2020 · 2 comments · Fixed by #10962

Comments

@michelou
Copy link
Contributor

michelou commented Jul 12, 2020

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).

@griggt
Copy link
Contributor

griggt commented Dec 31, 2020

This seems to have been fixed by #9618.

griggt added a commit to griggt/dotty that referenced this issue Dec 31, 2020
@michelou
Copy link
Contributor Author

michelou commented Jan 1, 2021

Confirmed.

@michelou michelou closed this as completed Jan 1, 2021
odersky added a commit that referenced this issue Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants