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
Emit migration warnings under -Xsource:3
as fatal warnings, not errors; -Xmigration
turns off erroring
#10439
Conversation
Remember to update the "override parens" checks, which still just error under Summary: instead of deprecation and then error under This change means projects can use |
88537a6
to
8ed0075
Compare
8ed0075
to
c850aeb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new warning category looks good to me, it allows making Scala 3 migration warnings fatal without -Werror
(which is what 2.13 currently does under -Xsource:3
).
-Wconf:cat=migration:e -Xmigration -Xsource:3
is bit much 🙂 Maybe -Xsource:3
can be enough?
- What's the value in
-Xmigration
changing the category in which these new warnings are emitted (deprecations vs Scala 3 migration)? - Can we have a
postSetHook
such that-Xsource:3
enables-Wconf:cat=scala3migration:e
?
There should be a test to ensure @nowarn
works (it does):
➜ sandbox qs -Wconf:cat=migration:e -Xmigration -Xsource:3
Welcome to Scala 2.13.12-20230623-225806-c850aeb (OpenJDK 64-Bit Server VM, Java 17.0.6).
Type in expressions for evaluation. Or try :help.
scala> @annotation.nowarn def f { println() }
def f: Unit
I felt bad that That isn't where I wound up in this PR when I tossed a dart, or a couple of darts. One is embedded in the wall over by the pinball machine. Summarizing again, all messages affected by The scary part is "error by default". Seth will have to pin "Did you add |
c850aeb
to
ce9b345
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the PR does this: if -Xsource:3
and the user didn't specify `cat=migration", set a default:
- if
-Xmigration
is set,cat=migration:error
cat=migration:warning
- else
:warning
:error
IMO it's still unnecessarily complicated. We have -Wconf
and a specific category for Scala 3 migration warnings, I'd leave -Xmigration
out of the picture.
[edit: -Xmigration
is an often forgotten child and maybe not as useful as it could be, but it has a sort of defined functionality in combination with the annoation.-Xmigration
as a shortcut to demote migration errors seems fine]
It migt also be confusing that the warning category changes depending on [edit: they are deprecations now, let's not change it]-Xsource
; a Scala 3 migration warning can remain in the Scala 3 migration category also under -Xsoruce:2
. This might in fact be useful.
@@ -353,11 +364,13 @@ object Reporting { | |||
|
|||
object JavaSource extends WarningCategory; add(JavaSource) | |||
|
|||
object Migration extends WarningCategory; add(Migration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala3Migration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just update the name? Also, I haven't thought about behavior when going from 2.12 to -Xsource:3, but maybe there is nothing special to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On 2.13 we only have migration warnings for going to 3.
I don't think we have any warnings on 2.12 about migrating to 3? 2.13 is required as an intermediate step.
I'd say Migration
would be fine if there wasn't already OtherMigration
. The Wconfs get a bit more noisy with Scala3Migration
but that might be a good thing.
It's the other way: But you're saying, just let them use And your other idea is to make current deprecations also migrations. My only qualm is that it is noisier. BTW, I am glad to tweak as much as necessary for ergonomics. |
Oh wait the part where it configures |
Ah, I got it wrong. Then keeping I see some tests use I overlooked the advantage of summarized deprecations, so I agree let's not change that, they are deprecations currently. I see the synthetic So yeah, LGTM, we're getting there! |
OK I'm awake again, I can ignore a few edits from earlier, but I'll wait a bit before making any rash decisions. |
The time I take to cook some crêpes and put the kids to bed is enough for you to get in your sleep and be back at compiler hacking... |
Restore override behavior, partest ++ on update Tweak Unicode escapes warning
93ac153
to
c290271
Compare
Simplify a few compiler flags in tests
val pts = pt.toString | ||
val leg = legacy.toString | ||
val help = if (pts != leg) s" instead of $leg" else "" | ||
runReporting.warning(tree.pos, s"under -Xsource:3, inferred $pts$help", WarningCategory.Migration, tree.symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
-Xsource:3
as fatal warnigns, not errors
-Xsource:3
as fatal warnigns, not errors-Xsource:3
as fatal warnings, not errors
This is a great improvement. |
Let's add a disclaimer to fatal-by-default warnings. People are not used to the fact that |
Yeah, I think we all have the associations pretty strongly in our minds that "error" = "compiler literally cannot continue", so some education will be needed here: in the error messages, in the PR description, and in the 2.13.12 release notes. |
I created a ticket scala/bug#12831 |
-Xsource:3
as fatal warnings, not errors-Xsource:3
as fatal warnings, not errors; -Xmigration
disables fatality
-Xsource:3
as fatal warnings, not errors; -Xmigration
disables fatality-Xsource:3
as fatal warnings, not errors; -Xmigration
avoids fatality
-Xsource:3
as fatal warnings, not errors; -Xmigration
avoids fatality-Xsource:3
as fatal warnings, not errors; -Xmigration
disables fatality
prepare Scala 2.13.12 - scala/scala#10439
@@ -154,6 +156,10 @@ trait Unapplies extends ast.TreeDSL { | |||
val mods = | |||
if (applyShouldInheritAccess(inheritedMods)) | |||
(caseMods | (inheritedMods.flags & PRIVATE)).copy(privateWithin = inheritedMods.privateWithin) | |||
.tap { mods => | |||
if (currentRun.isScala3 && mods != caseMods) | |||
runReporting.warning(cdef.pos, "constructor modifiers are assumed by synthetic `apply` method", WarningCategory.Scala3Migration, cdef.symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: what's the solution to this warning? I'm a bit confused by the message...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discord is pretty good for questions. There is a ticket to improve this warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@som-snytt scala/bug#12883 , or do you have some other ticket in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to create needless cross-reference noise... Probably this sounds like a "cross" reference.
-Xsource:3
as fatal warnings, not errors; -Xmigration
disables fatality-Xsource:3
as fatal warnings, not errors; -Xmigration
turns off erroring
This allows toning down / silencing Scala 3 migration warnings using
-Wconf
or@nowarn
.Scala 3 migration warnings are emitted as "fatal warnings" under category
scala3-migration
. Without-Xsource:3
, they continue to be reported as deprecations.Adding
-Xmigration
makes the migration warnings non-fatal (same effect as-Wconf:cat=scala3-migration:w
).Add a new warning for the case when an inferred type differs between Scala 2 and 3. Example:
Benign syntax enabled by
-Xsource:3
does not warn, such as relaxed import syntax.Fixes scala/bug#12798