Certain type aliases written in Scala 3 can't be used in Scala 2
Reproduction steps
Scala 2 version: 2.13.16 Scala 3 version: 3.6.3
-
Clone this minimum reproducability case repository: https://github.com/jadenPete/scala-missing-from-classpath-bug-reproduction
-
Run
sbt compile -
Observe the following error:
[error] .../scala-missing-from-classpath-bug-reproduction/program/src/main/scala/Main.scala:8:18: Symbol 'type com.example.package.AnimalList' is missing from the classpath.
[error] This symbol is required by 'object com.example.Person'.
[error] Make sure that type AnimalList is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'Person.class' was compiled against an incompatible version of com.example.package.
[error] val mickey = Person(pets = List(goofy))
[error] ^
[error] one error found
Problem
Certain type aliases written in Scala 3 can't be transitively used by other Scala 2 targets (i.e. referenced in a Scala 2 target that, in turn, is depended on by another Scala 2 target). I'm not sure if this is specific to package objects, but something gets lost in translation when those Scala 3 type aliases are encoded in Scala 2's Pickle format instead of decoded directly from TASTy.
@jadenPete curious, what is your use case for that direction of Scala 3/2 interop / tasty reader?
We’re migrating our mostly Scala 2 monorepo to Scala 3. The build target with the type aliases was originally written in Scala 2. Unfortunately, it’s not feasible to immediately migrate everything that depends on it to Scala 3 because thousands of build targets to use it.
I should also note that we’ve tried migrating targets at the top of the dependency graph first, but that usually yields way more compiler errors than starting at the bottom.
We should at least evaluate this for 2.13.17. cc @bishabosha