Try to cross-compile Scio-core for Scala 3 #4638
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is meant to explore the possibility of making scio cross compile for Scala-3. For now the
scio-core
and a large part ofscio-test
do compile, with some of that compiled scio-test failing (more on that later).Missing dependencies
There are some missing dependencies, most notably from the twitter stack:
com.twitter
%%algebird-core
com.twitter
%%chill
com.twitter
%%chill-algebird
None of them are too problematic, requiring only the use of
CrossVersion.for3Use2_13
. This does mean that there are some additional dependencies of which the 2.13 version has to be resolved, as otherwise we would get classpath conflicts (same thing will have to be done for any downstream projects).Missing shapeless 2 for Scala 3 is not a major issue, as it only leads to 2 changes:
Various
Magnolify
modules are used inscio-test
andscio-avro
.Magnolify
appears to already have a similar draft PR, where they are waiting for a solution of a few pending issues, including some we independently need solved for here as well. For now magnolify modules and code that depends on it was moved to a scala-2 only module.Macros
Some macros were rewritten, with the missing ones having a suitable comment near them. Most of the problematic (for now) macros stem from the use of Magnolia.
While
Magnolia
does have a Scala 3 version, it has a fundamentally different API and implementation from the Scala 2Magnolia
, for now using Mirrors instead of macros. This means that not all previously supported types will work, including AnyVal, or any other non case class types. The good news is that an alternative implementation of Magnolia was being investigated (softwaremill/magnolia#321), where it could be possible to support all those types. Absolute worst case scenario - we can fork that.Another macro that remains unported for now is the
To.safe
method. It looks doable, but we would have to construct schemas manually, based on the passed types instead of using eval like before. It should be possible, but I did not have the time to take care of this myself yet, especially considering it is relatively non critical to compiling and running the core module and tests.Any macro annotations are being commented-out / ignored for now, until they will be added to the language.
Testing
Because of the previously mentioned missing magnolify dependencies, some test suites that relied on them were moved to a separate Scala-2 only module. Additionally, there were some individual tests that did not compile either, mostly because of the aforementioned lack of support of Scala 3 Magnolia for non case class types - those tests were simply commented out for now.
I haven't had the time to properly setup the environment and analyze the test outputs, but for now many more tests fail on Scala 3 than on Scala 2, with the common error message being something like: