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
Warn by default on mismatch of presence/absence of an empty parameter list when overriding #8846
Warn by default on mismatch of presence/absence of an empty parameter list when overriding #8846
Conversation
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.
Looks very fast.
Related linting: #8843
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.
This should be considered together with #8833. I think we should either do them both in a minor 2.13 release, or none. Like 8833, it would be great to have a rewrite for overrides.
c50606f
to
226273f
Compare
This comment has been minimized.
This comment has been minimized.
|
Still faster than deprecating in 3.0 and removing in 3.1. 😄 |
20aaee2
to
93c2664
Compare
93c2664
to
595a127
Compare
595a127
to
6ae3b2a
Compare
6ae3b2a
to
4216bb1
Compare
this seems ready for merge, but holding off for now until #8833 is also ready |
@dwijnand needs rebase |
@dwijnand this is just a lint and not an actual deprecation... right? |
Yeah, I guess? I meant "deprecate" in "phase out" sense. Happy to call it a lint change. |
4216bb1
to
88e4569
Compare
88e4569
to
f491020
Compare
Aka "promote -Xlint:override-nullary". This means warn by default & error under -Xsource:3.
f491020
to
43438a6
Compare
@dwijnand could you improve the PR description to document this for folks who don't already know the context/motivation? |
In Scala 3 a method
def foo: A
(known as a "nullary" method) cannot override a methoddef foo(): A
(recently coined as a "nilary" method - because it contains one, empty parameter list). We now warn in Scala 2.The reverse (overriding
def foo()
withdef foo
) now also warns. But Java-defined methods are exempt, since Java doesn't have nullary methods but Scala users may wish to override non-side-effecting methods as nullary, for exampleoverride def toString = ...
.This behavior was already available via
-Xlint:nullary-override
, but now warns by default, and errors under-Xsource:3
.-Xlint:nullary-override
is no longer accepted.Strongly related to deprecating auto-application (#8833).