Skip to content
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

Scala 3 without Scala 2.13 toolchain #1383

Merged
merged 32 commits into from
Nov 16, 2023
Merged

Scala 3 without Scala 2.13 toolchain #1383

merged 32 commits into from
Nov 16, 2023

Conversation

lolgab
Copy link
Member

@lolgab lolgab commented Nov 13, 2023

Motivation

Until now Ammonite for Scala 3 was compiled using a mix of the Scala 2.13 and the Scala 3 compiler.
This was great since it allowed us to have Ammonite on Scala 3 before fastparse, mainargs and other libraries were even supported on Scala 3, or they were not on par with their Scala 2.13 counterpart.
Now that the ecosystem has caught up with Scala 3, we can avoid using Scala 2.13 and do everything with Scala 3.
This has the benefit that now all the classpath contains only Scala 3 libraries and we can finally invoke Scala 3 macros in the included libraries like upickle.
Also, the build gets much simpler since we don't have to do tricks to swap dependencies at runtime and manually remove transitive dependencies.
The only dependency that still is on Scala 2.13 is scalameta common, for which we still force the Scala 3 version of its sourcecode dependency to avoid double dependencies at runtime.

uPickle macros on Scala 3

upickle

Breaking changes

  • Drop support for Scala 3.1
  • Drop support for Scala 2.13.0
  • Scala 3 artifacts don't have the -cross naming convention anymore but are just like Scala 2 artifacts except for the _3 or _3.x.y suffix
  • ammonite.util.Bind now depends on typename instead of scala-reflect (which doesn't have a Scala 3 counterpart
  • scala-java8-compat updated to 1.0.2
  • mainargs updated to 0.5.4
  • requests updated to 0.8.0
  • interp.api.APIHolder.value is now final
  • typeOf removed from Scala 3 API (was not supported already)
  • Vararg command line arguments now use mainargs.Leftover

Pull request: #1383

Fixes: #1250

@lolgab lolgab changed the title Compile Scala 3 version using only dotty [WIP] Compile Scala 3 version using only dotty Nov 13, 2023
@lolgab lolgab changed the title [WIP] Compile Scala 3 version using only dotty Scala 3 without Scala 2.13 toolchain Nov 14, 2023
@lolgab lolgab marked this pull request as ready for review November 14, 2023 16:47
uPickle 3 doesn't have a version that supports
Scala 3.1, so I'm dropping it's support
Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not that intimate with the Ammonite code base, so I just bikeshedded a bit below. Otherwise, this looks reasonable to me.

build.sc Outdated Show resolved Hide resolved
.mill-version Outdated Show resolved Hide resolved
@lolgab
Copy link
Member Author

lolgab commented Nov 15, 2023

@alexarchambault @lihaoyi Can I have another review?

fastparse doesn't support it anymore
Some modules are cross-compiled to only one Scala 3 version which needs
to be the oldest Scala 3 version, otherwise we can't make other modules
depend on it.
So we run tests by passing the binary version and let mill choose the
last available Scala version that matches
This seems to be a bug in mill which doesn't allow to mix modules with
different Scala 3 versions. Adding a workaround in the build by
overriding a ScalaModule target
@lihaoyi
Copy link
Member

lihaoyi commented Nov 16, 2023

Looks reasonable to me. If the test suite passes that gives us confidence that nothing broke

@lihaoyi
Copy link
Member

lihaoyi commented Nov 16, 2023

-350 lines of code is also very nice, given how gnarly a lot of the deleted code is

@lolgab lolgab merged commit cf9a7b8 into com-lihaoyi:main Nov 16, 2023
17 checks passed
@lolgab lolgab deleted the scala-3 branch November 16, 2023 15:24
@lefou lefou added this to the 3.0.0-M1 milestone Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to embed Ammonite-REPL in Scala 3?
3 participants