scala 3 sealed trait object can't be referenced from scala 2
See original GitHub issueCompiler version
3.1.3 with 2.13.8 (it doesn’t occur with 3.1.2 or 3.0.2 together with 2.13.8)
Minimized code
This requires a multi project sbt build with one small file in each project. The easiest reproduction is from https://github.com/johnduffell/tasty-tuple-issue
git clone git@github.com:johnduffell/tasty-tuple-issue.git
sbt scala2/compile
A summary is that with this code in scala 3, AValue
can’t be referenced from scala 2
sealed trait Scala3ADT
object Scala3ADT {
case object AValue extends Scala3ADT
}
Output
compiler error: Unsupported Scala 3 generic tuple type scala.Tuple in bounds of type MirroredElemTypes; found in scala.deriving.Mirror.<refinement>.
Full output is:
[info] welcome to sbt 1.7.1 (AdoptOpenJDK Java 1.8.0_275)
[info] loading settings for project global-plugins from plugins.sbt ...
[info] loading global plugins from /Users/john_duffell/.sbt/1.0/plugins
[info] loading project definition from /Users/john_duffell/code/tasty-tuple-issue/project
[info] loading settings for project root from build.sbt ...
[info] set current project to tasty-tuple-issue (in build file:/Users/john_duffell/code/tasty-tuple-issue/)
[info] compiling 1 Scala source to /Users/john_duffell/code/tasty-tuple-issue/scala3/target/scala-3.1.3/classes ...
[info] compiling 1 Scala source to /Users/john_duffell/code/tasty-tuple-issue/scala2/target/scala-2.13/classes ...
[error] Unsupported Scala 3 generic tuple type scala.Tuple in bounds of type MirroredElemTypes; found in scala.deriving.Mirror.<refinement>.
[error] one error found
[error] (scala2 / Compile / compileIncremental) Compilation failed
[error] Total time: 6 s, completed 17-Aug-2022 22:56:25
Expectation
The code should compile correctly.
Notes
It appears that scala.Tuple
is expected to be erased by the scala 3 compiler, so it wouldn’t be found by scala 2 tasty reader.
However it appears that the Mirror created for sealed traits has a member with Tuple as a type contstraint, which then seems to not be erased and trips things up.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
thanks, I will revert to 3.1.2 until there is 2.13.9 out. This was a massive head scratcher!
@johnduffell you can always get a debug trace for tasty reading if you use the flag
-Ydebug-tasty
on the scala 2 compiler, adding-Ydebug
flag at the same time will trace even more fine grained detail