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 publishing plan #2485
Comments
This looks like a great plan! Thank you for initiating this discussion. What 2.13 dependencies cause most problems for downstream users? I’m curious if we can replace them somehow so scalameta_2.13 will be dependency free or only depend on Scala 3 libraries (using the 2.13 tasty reader). |
The common annoyances are:
|
Given that fastparse is already shadowed, we can do the same with geny and sourcecode |
Is it possible to use the 2.13 tasty reader to upgrade those dependencies to Scala 3? |
So you mean having fastparse_2.13 depend on geny_3 and sourcecode_3 instead? I think this will lead to opposite problem in 2.13 artifacts downstream (i.e. mdoc_2.13), as they will now have _3 artifacts resolved and SBT will barf again. Is this what you meant? |
You are right, that will cause problems for 2.13 artifacts. Can we inline those dependencies instead (excluding protobuf) to make them disappear? Both geny and sourcecode are tiny, and I suspect we're not using scala-collection-compat in many places. |
It would of course be ideal if we can build Scalameta against Scala 3, but the checklist above shows that it will require a lot of effort. There shouldn't be any technical problems for Scala 3 users to consume scalameta_2.13 if it doesn't bring transitive 2.13 dependencies. |
Yep, I'm all for inlining at first, to remedy the current pain points. I'm still eager to at least start on some of the macros, but may be in a separate sbt module. Will need a bit of rejigging to have at least some tests run against those, but I want to minimise the churn for the contributors to the main parts of scalameta. |
Modified the plan to inline both sourcecode and geny first, as it's best risk/reward move at this stage. |
@keynmol what's the status (beyond the comments in here) on this effort? I'm sure it's a big effort but it's forcing me into 2.13.10 vs 3.x since I need quasiquote support. |
We discussed it recently during the Scala tooling summit and this is non-trivial migration. We might at some point pursue a simpler macro system for Scala 3, but we haven't decided on anything yet. |
Here are my notes from the tooling summit, note that this is focused on porting all of scalameta which is why it mentions the core macro annotation, but we might instead prioritize porting the quasiquotes macros to make scalameta more usable from Scala 3, we didn't investigate those during the summit. During our in-person discussion we mostly focused on the
|
Any guess when this might happen? |
Not currently no, but you can use the Scalameta 2.13.x version in Scala 3 currently. |
Would you mind giving me a dummy's explanation of how to use Scalameta 2.13.x in my Scala 3 project please? |
libraryDependencies += ("org.scalameta" %% "scalameta" % "4.8.14").cross(CrossVersion.for3Use2_13), We use parser like this in twirl: https://github.com/playframework/twirl/blob/382474d3ebc3761b37cb1af7138926fcb4364159/build.sbt#L119 |
I did not find a tracking issue for this, but please point me to it if there is one.
For full transparency, I don't know if it's necessary to publish Scalameta for Scala 3. It would certainly be nice for end users (such as mdoc and its end users) not to propagate the 2.13 versions of certain libraries Scalameta uses.
Straight up publishing for Scala 3 is complicated by the heavy usage of Scala 2 macros, as such a very quick grep shows that at least this many macros/usages of macros will need to be re-written:
And those macros are split into two major categories:
Macro annotations - which are currently not supported at all in Scala 3, for example: https://github.com/scalameta/scalameta/blob/main/scalameta/common/shared/src/main/scala/scala/meta/internal/trees/ast.scala#L11
Faced with the same problem, Cats replaced their macros with Scalafix codegeneration: https://github.com/typelevel/simulacrum-scalafix without breaking any APIs.
Various other macros, whitebox and blackbox. Scala 3's macros are more restricted, but probably most things can be implemented, if may be using slightly different techniques.
Fastparse
Scalameta depends on Fastparse but not for the main parser, rather the auxiliary ones - XML and Scaladoc, e.g. https://github.com/scalameta/scalameta/blob/fb8bee548061d75397b5fea9fb5a3d3e1aabecd0/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScaladocParser.scala
Fastparse is a heavily macro-based project, and while some preparation work has started for Scala 3 port: com-lihaoyi/fastparse#252 I'm not sure it will be easy or will progress quickly.
Fast parser options are thin on the ground for Scala 3 atm, cats-parse being the only one published and comparable in performance (afaik). Perhaps a hand-rolled parser will be easier or a macro-less version of Fastparse for Scala 3...
Consideration: Scalameta is an active project, powering several very important tools in the ecosystem, and the macro work above is a multi-week/month invasive undertaking.
To make it possible, some preliminary work needs to happen:
scala.meta.internal.sourcecode
package and dependency removed from the buildscala.meta.internal.geny
package and dependency removed from the buildscala-2
folders in thecommon
module- This allows the Scala 2 version to compile and operate without changes
- The work on porting the macros can continue in parallel in separate sources,
scala-3
foldersrc/main/scala
, if it can be cross-compiled (I've done this exercise, there's not that many files, sadly)The text was updated successfully, but these errors were encountered: