Using Scala 3 unique features while cross-building with Scala 2

There is something I don’t understand in the concept of library management across Scala 2 and 3, in regards to new Scala-3-only features. How do we avoid having completely different sources for cross-building if we take advantage of these new features?

For example, top-level definitions + export in Scala 3 vs package object + inheritance in Scala 2. When I think about how I arrange my library today in Scala 2, and how I can (finally) arrange it better in Scala 3, I notice a very significant variance. Sure, I can ignore the new features of Scala 3 and aim for cross-building commonality, but then what is the point? It’s like having a Scala 2 project with a Scala 3 compiler.

Can we rely on just binary-compatibility (java class / TASTy) across 2.13 and 3 and ignore cross-building (macros should be handled differently of course)?

3 Likes

I thought you would even be able to include Scala 2 macros in Scala 3 code and publish for Scala 3 and use it in a Scala 2 project

1 Like