Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add-quickfix compiler option to apply quickfixes to source files#10482

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
SethTisue merged 1 commit intoscala:2.13.xfromlrytz:quickfix
Aug 15, 2023

Conversation

@lrytz
Copy link
Member

With 2.13.12 the compiler starts providing quick fixes with certain warnings and errors. Typically these are presented in IDEs, however it can also be practical to have the compiler directly patch the source files.

From-quickfix:help:

Apply quick fixes provided by the compiler for warnings and errors to source files.Syntax: -quickfix:<filter>,...,<filter><filter> syntax is the same as for configurable warnings, see `-Wconf:help`. Examples:  -quickfix:any                    apply all available quick fixes  -quickfix:msg=Auto-application   apply quick fixes where the message contains "Auto-application"Use `-Wconf:any:warning-verbose` to display applicable message filters with each warning.

He-Pin, manfredi-giordano, and fommil reacted with thumbs up emojisom-snytt, eloots, jozic, He-Pin, SethTisue, and rtyley reacted with heart emoji
@scala-jenkinsscala-jenkins added this to the2.13.13 milestoneAug 3, 2023
@lrytzlrytz modified the milestones:2.13.13,2.13.12Aug 3, 2023
@lrytzlrytzforce-pushed thequickfix branch 3 times, most recently froma7bd1db to3505209CompareAugust 3, 2023 19:33
With 2.13.12 the compiler starts providing quick fixes with certainwarnings and errors. Typically these are presented in IDEs, howeverit can also be practical to have the compiler directly patch the sourcefiles.From `-quickfix:help`:```Apply quick fixes provided by the compiler for warnings and errors to source files.Syntax: -quickfix:<filter>,...,<filter><filter> syntax is the same as for configurable warnings, see `-Wconf:help`. Examples:  -quickfix:any                    apply all available quick fixes  -quickfix:msg=Auto-application   apply quick fixes where the message contains "Auto-application"Use `-Wconf:any:warning-verbose` to display applicable message filters with each warning.```
@SethTisueSethTisue added prio:hihigh priority (used only by core team, only near release time) release-notesworth highlighting in next release notes labelsAug 8, 2023
@SethTisueSethTisue changed the titleAdd -quickfix compiler option to apply quick fixes to source filesAdd-quickfix compiler option to apply quick fixes to source filesAug 13, 2023
@SethTisueSethTisue merged commit86f40c2 intoscala:2.13.xAug 15, 2023
@SethTisueSethTisue removed the prio:hihigh priority (used only by core team, only near release time) labelAug 23, 2023
@SethTisueSethTisue changed the titleAdd-quickfix compiler option to apply quick fixes to source filesAdd-quickfix compiler option to apply quickfixes to source filesAug 23, 2023
dongjoon-hyun pushed a commit to apache/spark that referenced this pull requestSep 30, 2023
### What changes were proposed in this pull request?This pr aims to upgrade Scala from 2.13.11 to 2.13.12.Additionally, this pr adds ``-Wconf:msg=legacy-binding:s`` to suppress similar compiler warnings as below:```[ERROR] /Users/yangjie01/SourceCode/git/spark-mine-13/core/src/main/scala/org/apache/spark/deploy/client/StandaloneAppClient.scala:171: reference to stop is ambiguous;it is both defined in the enclosing class StandaloneAppClient and inherited in the enclosing class ClientEndpoint as method stop (defined in trait RpcEndpoint, inherited through parent trait ThreadSafeRpcEndpoint)In Scala 2, symbols inherited from a superclass shadow symbols defined in an outer scope.Such references are ambiguous in Scala 3. To continue using the inherited symbol, write `this.stop`.Or use `-Wconf:msg=legacy-binding:s` to silence this warning. [quickfixable]Applicable -Wconf / nowarn filters for this fatal warning: msg=<part of the message>, cat=other, site=org.apache.spark.deploy.client.StandaloneAppClient.ClientEndpoint.receive```### Why are the changes needed?The new version bring some regression fixes:-scala/scala#10422-scala/scala#10424And a new feature: Quickfixes```For some errors and warnings, the compiler now suggests an edit that could fix the issue. Tooling such as IDEs can then offer the edits, or the compiler itself will make the change if run again with -quickfix.```-scala/scala#10406-scala/scala#10482-scala/scala#10484The release notes as follows:-https://github.com/scala/scala/releases/tag/v2.13.12### Does this PR introduce _any_ user-facing change?Yes, Scala version changed.### How was this patch tested?Pass Github### Was this patch authored or co-authored using generative AI tooling?NOCloses#43185 from LuciferYang/SPARK-45331.Authored-by: yangjie01 <yangjie01@baidu.com>Signed-off-by: Dongjoon Hyun <dhyun@apple.com>
rtyley added a commit to guardian/tagmanager that referenced this pull requestOct 22, 2024
…`()` is deprecatedScala 2.13 deprecates (with PRscala/scala#8833) the old behaviour of Scala that zero-parameter methods could be called with either one or zero pairs of parenthesis - ie if you have a method `def foo()` you could call it as `foo()` or just `foo`. With Scala 3, you have to match the number of brackets *used in the method declaration* when you call it - so you'd _have_ to use `foo()` or you'd get an error like this:```[error] ~/code/presence-indicator/app/actor/OpenSocketActor.scala:79:7: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method sender,[error] or remove the empty argument list from its definition (Java-defined methods are exempt).[error] In Scala 3, an unapplied method like this will be eta-expanded into a function. [quickfixable][error]       sender ! Map(serverId -> (LiveActors(connectionPing, subscription)))[error]       ^```Java methods are exempt from this restriction - you can call either `hashCode()` (which, in Java, is how the method _has_ to be defined, with empty brackets) or just `hashCode` (which is how that method would have been declared if it was declared in Scala, in Scala methods with no side-effects should be declared without brackets:https://docs.scala-lang.org/style/method-invocation.html#arity-0).## Automatically fixing this code issueThere are two possible ways of automating this code fix - in this small project, they both produce the same code changes:### Fixing if the project is already on Scala 2.13 - use `-quickfix` in `scalac`You can use the `-quickfix` support added to Scala 2.13.12 withscala/scala#10482:Add either of these to the `scalacOptions` in `build.sbt`:* `"-quickfix:any"`  ...to apply *all* available quick fixes* `"-quickfix:msg=Auto-application"`  ...to apply quick fixes where the message contains "Auto-application"Then run `compile` on the sbt console - the first compile will still fail, but it will subtly change the error message to say `[rewritten by -quickfix]` - your files have been edited to receive the fix:```[error] /Users/Roberto_Tyley/code/presence-indicator/app/actor/OpenSocketActor.scala:79:7: [rewritten by -quickfix] Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method sender,[error] or remove the empty argument list from its definition (Java-defined methods are exempt).[error] In Scala 3, an unapplied method like this will be eta-expanded into a function.[error]       sender ! Map(serverId -> (LiveActors(connectionPing, subscription)))[error]       ^```...run `compile` a second time, and compiler will be much happier.Examples of other PRs using `-quickfix` to fix this code issue:*guardian/ophan#5719### Fixing while still on Scala 2.12 - use ScalafixFixing this everywhere in a project can be tedious, but thankfully there is a `ExplicitNonNullaryApply` Scalafix rule to fix this in thehttps://github.com/lightbend-labs/scala-rewrites project.The Scalafix rule needs to be run while the project is still on Scala 2.12, not Scala 2.13 (otherwise sbt will say: "Error downloading ch.epfl.scala:sbt-scalafix;sbtVersion=1.0;scalaVersion=2.13:0.13.0").Once the Scalafix plugin is made available to sbt (by adding `addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0")`to either `project/plugins.sbt` or `~/.sbt/1.0/plugins.sbt`), you can run these commands on the sbt prompt to automatically generate the changes in this PR:```scalafixEnablescalafixAll dependency:fix.scala213.ExplicitNonNullaryApply@org.scala-lang:scala-rewrites:0.1.5```Examples of other PRs using Scalafix to fix this code issue:*guardian/mobile-apps-api#2728*guardian/presence-indicator#196See also:*scalacenter/scalafix#204*lightbend-labs/scala-rewrites#14
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

release-notesworth highlighting in next release notes

Projects

None yet

Milestone

2.13.12

Development

Successfully merging this pull request may close these issues.

3 participants

@lrytz@SethTisue@scala-jenkins

[8]ページ先頭

©2009-2025 Movatter.jp