-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Command line options to control Scala versions and migration? #8571
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
Comments
|
I think having the semantics of |
My understanding is that -Xsource is not officially supported/recommended because it's only very lightly tested (ideally you'd want to run the whole test suite with every value of the flag) /cc @SethTisue |
Yeah, that's right: scala/bug#11661 |
There's the immediate problem that we should not have a flag Also, there are the following scenarios, which I don't see how to support with a single flag:
The combination of |
It's not much or of a lie than having
I think that all of those scenarios can be handled by the new configurable warning mechanism from scala/scala#8373, which we should implement and consider improving before adding a separate overlapping warning mechanism control just for migration. |
I think we can do a credible job to support I do not think configurable warnings is a substitute, and am in fact quite sceptical about that development. The reason I am sceptical about configurable warnings is that it could start a development where we end up with another complex nightmare like sbt. Because warnings are now configurable, there will be many more of them, with intricate categories for flitering. I somehow do not think that's the right way to go! |
Concrete scenario: I am using the 3.1 compiler (because it's great!) but our code base is on 3.0 (because cross-compile). I compile with
But that's not what I want! I want it to accept all 3.0 features without warnings. Instead I want errors if a 3.1 feature is used in that codebase. |
You mean, cross-compile with 2.13 ? If this is a common usecase, then maybe we just need to ensure that we can cross-compile between 2.13/3.1 the same way we can between 2.13/3.0.
How do we define what a 3.1 feature is ? Is this about source-compat, tasty-compat, binary-compat, or all of them ? |
If I'm using |
We probably can't: Let's say 3.1 will drop support for implicits. How do you cross-compile then? About coverage: It's source compat, and language only. Libraries are not affected. I believe that's also the case for Java. |
One possible refinement would be to have a separate source level for 2.13/3.0 cross compiles. Something like |
I had this question the other day because of the migration section on "Given Imports / Importing Givens". I wanted strict behavior of wildcard import of implicits, but didn't know how to ask for In Scala 2,
On the other hand, I do care about old deprecations. My deprecator plugin would turn old deprecations into errors, for example, warnings older than 2.12. Deprecations are really a kind of migration message. But policy around how they are managed is not trivial. Summaries such as I agree warnings should be limited, or rather eliminated, except for Even deprecations can be pushed to an external linter. In Scala 2, deprecations are emitted for language changes, but I agree that warning suppression is a symptom of too many warnings to manage. Sometimes it's easier to shut down all the trash compactors on the detention level. |
Scenarios:
Are there other scenarios that we should consider? |
@sjrd If you have time, your opinion on this subject would be appreciated :) (Martin is planning to implement this stuff soon). |
What would these flags do? Would In 2.13 we're following the strategy that |
Yes, it would try to do some approximation of that. Violations would be errors,
No, for that you would need
It only rewrites code in conjunction with
|
Fix #8571: A new source version and migration scheme
Uh oh!
There was an error while loading. Please reload this page.
We should regularize our options for controlling language versions and migration.
The current state
-language:Scala2Compat
-migration
-rewrite
-migration
perform some rewrites from Scala 2 -> Scala 3-strict
A possible alternative
-source
3.0
,3.1
.3.0
is the default.-migration
-source
is 3.1) and migration warnings are issued where something is no longer supported without-migration
in the new source version. Migration warnings are always emitted, never bunched-rewrite
-migration
perform some automatic rewrites from old to new versionSo, we'd have the following equivalences between current state and alternative:
-language:Scala2Compat -migration
maps to-source 3.0 -migration
or simply-migration
-language:Scala2Compat -migration -rewrite
maps to-migration -rewrite
-strict
maps to-source 3.1
-language:Scala2Compat
alone does not map to anything -- you can't support dropped features without migration warnings.Btw, what was the motivation in Scala 2 to use
-Xsource:version
instead of-source version
as Java does? It seems source version should be a standard option, so-X
seems out of place.The text was updated successfully, but these errors were encountered: