-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Audit which private/fork (-Y*
) options should be lifted to one of the stable categories
#19693
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
Perhaps there are |
I'm not suggesting to get rid of For example, options related to capture checking (like |
Most -Y options are debug options to get more insight into what the compiler does or they are options relating to experimental features. Another bunch is options that tweak the compiler output, but that need expert knowledge to understand what they do. I think these can stay. But the following could be reclassified as -X options since they have been used for a while and are compiler-independent. val YnoImports: Setting[Boolean] = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
val Yimports: Setting[List[String]] = MultiStringSetting("-Yimports", helpArg="", "Custom root imports. If set, none of scala.*, java.lang.*, or Predef.* will be imported unless explicitly included.")
val YnoGenericSig: Setting[Boolean] = BooleanSetting("-Yno-generic-signatures", "Suppress generation of generic signatures for Java.")
val YnoPredef: Setting[Boolean] = BooleanSetting("-Yno-predef", "Compile without importing Predef.") And the following are about features that are in train of stabilization. They need a decision when they are stable in which case they could be promoted to -X options or become default behavior. val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ysafe-init", "Ensure safe initialization of objects.")
val YcheckInitGlobal: Setting[Boolean] = BooleanSetting("-Ysafe-init-global", "Check safe initialization of global objects.") |
There are also options related to old Scala versions like |
Actually, let's hold off on the imports settings. val YnoImports: Setting[Boolean] = BooleanSetting("-Yno-imports", "Compile without importing scala.*, java.lang.*, or Predef.")
val Yimports: Setting[List[String]] = MultiStringSetting("-Yimports", helpArg="", "Custom root imports. If set, none of scala.*, java.lang.*, or Predef.* will be imported unless explicitly included.")
val YnoPredef: Setting[Boolean] = BooleanSetting("-Yno-predef", "Compile without importing Predef.") We need to have a (SIP) discussion about that. In my view it is a code smell to fiddle with imports via a compiler option and not in source. So import Predef.{String as _}
object Test:
summon[Int] // error: not found: summon But that's very roundabout: (1) We need to know that the repeated import actually replaces the default one. (2) We need to import something and then rename it to nothing. It would be great if this worked for at least all root imports with a better syntax. My preferred syntax would be: import Predef.{}
import scala.{}
import java.lang.{} Or, as the note in override import Predef.{}
override import scala.{}
override import java.lang.{} In any case. I would not elevate -Y import options to officia;l status before this question is settled. |
Here's the note: /** The root import symbol hidden by this symbol, or NoSymbol if no such symbol is hidden.
* Note: this computation needs to work even for un-initialized import infos, and
* is not allowed to force initialization.
*
* TODO: Once we have fully bootstrapped, I would prefer if we expressed
* unimport with an `override` modifier, and generalized it to all imports.
* I believe this would be more transparent than the current set of conditions. E.g.
*
* override import Predef.{any2stringAdd => _, StringAdd => _, _} // disables String +
* override import java.lang.{} // disables all imports
*/
def unimported(using Context): Symbol = |
Maybe there are other options like -YnoGenericSig that suppress some output in the generated files. Maybe these could be moved to -X since the goal is presumably to cut down on generated file size, which easy to understand. |
Let me expand on this a bit. In the chat rooms, I've lost count of how many puzzled people we've had to inform that It's especially common that people try I've just opened scala/docs.scala-lang#2976 about improving the Scala 3 reference documentation to try and head off this problem, but I'm also interested in discussing possible changes like making known-dubious features like |
About It seems the most pressing issue is |
We have to strike a balance but putting things under more locks is not the right way to proceed. If we were a big organization we could develop a new feature behind walls, test it thoroughly and release it when it is fully cooked. But we are not. We rely on volunteer work without fixed schedules. So we can discuss about names. I personally think that all And, |
Sure, I was just pointing out that there's a valid use case. To me it's fine if For experimental language features I think it's worthwhile having one mechanism. |
Generally I agree. There is a complication that the three experimental extension options we have, (explicit nulls and the two check-init options) need to be turned on globally. They don't work (yet) for individual compilation units. So that means we can't use a language import for them. But we could insist on better naming. Maybe
? |
Or require |
I am not sure it would be desirable. These are checking options that don't change the binary or tasty output in any way. So I don't see why they would require transitiveness. |
I discussed with @liufengyun .
|
@olhotak @liufengyun I think we can just make it a PR for -Ysafe-init. |
The people who hate that it doesn't work the way they want would agree. I see it as a REPL feature (where it also avoided compilations on startup). But maybe scala-cli The use case for "ordinary user Joe" is starting a REPL with everything plugged into the namespace, without experimenting with "what imports are needed". Also, an The limitation of |
(ticket on that is VirtusLab/scala-cli#2732) |
We can probably remove |
About the -Yimport options. I think it's completely OK to compile with some customized root imports. But we should not express it using external options, but instead support it in the source code itself. I worked out a proposal in #19740. |
We could use a |
Reminder that These are flags that one would never leave enabled in one's build, so I don't think it's necessary to have any guarantees about In Scala 3, we already have some I think awareness in the community of |
After doing an initial analysis with @szymon-rd, here's an updated list of options to be lifted out of
Other than that, we should improve the help message for |
This looks mostly good to me, except for
|
@odersky Ok, removed @rochala I updated the list in #19693 (comment), let's treat it as the requirements for closing this issue. |
Fixes: #19693 This is the tracking list from the issue and the status of migraton. - [x] lift to `-X` - [x] `-Yresolve-term-conflict` - [x] `-YnoGenericSig` - [x] `-Ydumpclasses` - [x] `-YjarCompressionLevel` - [x] `-YkindProjector` - [x] `-YdropComments` - [x] `-YcookComments` - [x] `-YreadComments` - [x] `-YnoDecodeStacktraces` - [x] `-YnoEnrichErrorMessages` - [x] `-YdebugMacros` - [ ] `-YjavaTasty`- deprecate in 3.7.0 - [ ] `-YjavaTastyOutput`- deprecate in 3.7.0 - [ ] `-YallowOutlineFromTasty`- deprecate in 3.7.0 - [x] lift to `-W` - [x] `-Wsafe-init` - [x] to be removed - [x] `--Yforce-inline-while-typing` // Note: this was already removed by 05eb7f7 - [ ] TBD - [ ] `-YfromTastyIgnoreList` // this flag was not decided - [x] `-YoutputOnlyTasty` I suppose 2 last flags that have to be decided are maintained by @bishabosha Do you know their status ? Other than that, this PR implemented a deprecation mechanism for the future e.g. ```scala Deprecation( msg = "message", replacedBy = Some("newMessage"), ) ``` EDIT: As it was decided, options responsible for pipelining will be retained until 3.7.0. The code is commented and following PR which will deprecate them will be created after merging this one. EDIT2: `-Xlint` is a very problematic flag. It was added into the compiler in 3.4 bypassing argument verification. Then in the future, when it was deprecated in favour of `-Wshadow` we couldn't exactly map them 1-1, and it was deprecated in following way: - Scala 2: `-Xlint` is valid flag, - Scala pre 3.4: `-Xlint` was skipped as it was not implemented, - Scala post 3.4 pre flag refactor: `-Xlint` was implemented allowing for `all`, `private-shadow` and `type-parameter-shadow` options. It also bypassed argument verification allowing standalone `-Xlint` to be ignored, not reported as error, - Scala post 3.4 post flag refactor: This flag was then deprecated in favour of `-Wshadow`. We didn't want to commit this mistake again and allow standalone `-Wshadow` thus when it was deprecated, we didn't handle it as we should (deprecated option should trigger replacement when possible). That's why I'm retaining the previous behaviour of `-Xlint`. It will be removed in the future versions as it is already deprecated.
Compiler version
nightly
Context
A number of
-Y*
options are considered private (unstable
), while in reality they're widely used and could be considered production-ready.We need to look at them case-by-case, potentially lift them to their appropriate categories and deprecate their
-Y*
aliases, where applicable.Consider this an umbrella ticket to tidy this up.
The text was updated successfully, but these errors were encountered: