Skip to content
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

Deprecate auto-application of (non-Java-defined) methods with a single empty parameter list #8833

Merged
merged 1 commit into from Jun 2, 2020

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 27, 2020

Auto-application is dropped in Scala 3:
https://dotty.epfl.ch/docs/reference/dropped-features/auto-apply.html

So it must be deprecated in 2.13 first.

Strongly related to deprecating overriding nullary (and the inverse, overriding nilary): #8846.

Example

$ scala -deprecation -e 'println'
...
warning: Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method println,
or remove the empty argument list from its definition (Java-defined methods are exempt).
In Scala 3, an unapplied method like this will be eta-expanded into a function.
println
^

How to fix

It is recommended to add the missing parens:

$ scala -deprecation -e 'println()'

The change can be made manually or by using scala-rewrites' ExplicitNonNullaryApply.

How to suppress

Since 2.13.2, Scala offers -Wconf:... and @nowarn for warning suppression. You can suppress the new warning globally by passing -Wconf:cat=deprecation&msg=Auto-application:silent to the compiler, or you can suppress it locally by adding @nowarn("cat=deprecation&msg=Auto-application") at the call site.

@scala-jenkins scala-jenkins added this to the 2.13.3 milestone Mar 27, 2020
@dwijnand dwijnand force-pushed the fast-deprecate-auto-application branch from 40187f6 to 073c8ef Compare March 27, 2020 09:41
@lrytz lrytz closed this Mar 27, 2020
@lrytz lrytz reopened this Mar 27, 2020
@lrytz
Copy link
Member

lrytz commented Mar 27, 2020

Is there (or could we write) a scalafix rule supporting this change? Scalafix exists for 2.13.1.

@SethTisue
Copy link
Member

Let's leave this one for 2.13.3.

@dwijnand
Copy link
Member Author

dwijnand commented Apr 3, 2020

Is there (or could we write) a scalafix rule supporting this change?

lightbend-labs/scala-rewrites#14

@dwijnand dwijnand force-pushed the fast-deprecate-auto-application branch 2 times, most recently from 31fbcf6 to d51c962 Compare April 9, 2020 21:12
@SethTisue SethTisue added the prio:hi high priority (used only by core team, only near release time) label May 12, 2020
@dwijnand dwijnand force-pushed the fast-deprecate-auto-application branch from d51c962 to c78ffa1 Compare May 20, 2020 07:00
@dwijnand dwijnand force-pushed the fast-deprecate-auto-application branch from c78ffa1 to f6c89f7 Compare June 1, 2020 06:55
Auto-application is dropped in Scala 3:
https://dotty.epfl.ch/docs/reference/dropped-features/auto-apply.html

So it must be deprecated in 2.13 first.

Also, AFAICT Object_clone is Java-defined:

    $ qscala
    Welcome to Scala 2.13.2-20200325-150327-bc1cad4 (OpenJDK 64-Bit Server VM, Java 11.0.6).
    Type in expressions for evaluation. Or try :help.

    scala> :power
    Power mode enabled. :phase is at typer.
    import scala.tools.nsc._, intp.global._, definitions._
    Try :help or completions for vals._ and power._

    scala> Object_clone.isJavaDefined
    val res0: Boolean = true
@SethTisue SethTisue force-pushed the fast-deprecate-auto-application branch from f6c89f7 to c900df8 Compare June 1, 2020 22:32
Copy link
Member

@SethTisue SethTisue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

force-pushed to bump the deprecated-since from 2.13.2 to 2.13.3. let's merge as soon as CI likes it again

@SethTisue SethTisue changed the title Fast-track deprecating auto-application Deprecate auto-application of (non-Java-defined) methods with a single empty parameter list Jun 1, 2020
@SethTisue SethTisue removed the prio:hi high priority (used only by core team, only near release time) label Jun 1, 2020
@SethTisue

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
4 participants