-
Notifications
You must be signed in to change notification settings - Fork 224
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
Support for some Scala 3 syntactic constructs in Scala 2 with -Xsource:3 #2323
Comments
Thanks for the heads up! We have three choices here:
I would honestly opt for Opinions, anyone? @olafurpg @ckipp01 @kitbellew @mlachkar ? |
@tgodzik scalafmt rewrite rules use these flags, so they had better be enabled in reality. given the previous difficulty in supporting
maybe even add a |
@tgodzik I think the second option will be the safest one. Anyway, people had to enable |
I think the number of people upset by the latter will dwarf the number of people upset by the former :). Anyway, I'd like to note that this particular change is less important than the first two changes ( |
Oh, I mean a different thing. I'm only about that it would be better not to enable Let's say someone uses So I think the best option here would be the second one where each tool detects this flag/has a setting to enable new syntax. |
Yeah, those soft keywords are not too safe and would lead to unexpected situations. |
You'd have to use it in a very specific position to run into an issue (on a line by itself just before a |
i'd vote for users explicitly telling the scalameta-integrating tool that they want 2.13.6' rather than plain vanilla 2.13.6. after all, after decades of using |
Speaking of dialect, I assume that Scala3 will become the default dialect once Scala 3.0 is out? In that case whether or not a new dialect is used to support these constructs won't matter so much if the default already support them. |
I think |
Also, we cannot possibly force everyone to set Scala 2 dialect in their projects. We will try to add some improvements so that users will know they need to add the new option. |
I agree that the default dialect should remain Scala 2 for a while even after the 3.0 release. Changing the default dialect to Scala 3 could cause breakages for all Scala 2 users. |
After a bit of thought. Can't we just use dialect for Scala3 in cases where user enables the new option? If it's supposed to make sure that the code will compile with Scala 3, it might be even better to use that dialect. We wouldn't need to do anything in scalameta and in metals we can just check if the version is 2.13.6 or above and that the new setting is set. In that case we would parse everything automatically with the Scala 3 dialect. |
Is the Scala 3 dialect a superset of the Scala 2 one? Otherwise this could be problematic since using -Xsource:3 does not mean that all your code can be parsed by Scala 3, you might have some Scala 2 macros in a scala-2/ folder for example. |
Ach ok, i thought that the option is much more limiting. We'll need a new dialect then when 2.13.6 comes out |
Well, looking at https://github.com/scalameta/scalameta/blob/main/scalameta/dialects/shared/src/main/scala/scala/meta/dialects/package.scala I think it might be OK since most of the things which are disallowed are already deprecated in Scala 2, however:
That's incorrect, we still support xml literals with scala-xml on the classpath like Scala 2.
We still support them under a language flag, so I would leave that to true. |
Not sure if this is the correct place to discuss this, but this is a heads-up that Scala 2.13.6 and 2.12.14 will support a subset of the Scala 3 syntax under
-Xsource:3
:These are all just parser changes intended to ease cross-compilation and it would be great if metals/scalameta/scalafmt/scalafix/... could understand these constructs in a Scala 2 codebase without the user having to do anything in particular. Note that while all these changes are currently under
-Xsource:3
, some of them might end up being enabled by default in future Scala 2 releases to ease migration.The text was updated successfully, but these errors were encountered: