Warn by default on mismatch of presence/absence of an empty parameter list when overriding#8846
Merged
SethTisue merged 1 commit intoscala:2.13.xfrom Jun 3, 2020
Conversation
c50606f to
226273f
Compare
dwijnand
commented
Mar 31, 2020
This comment has been minimized.
This comment has been minimized.
Contributor
|
|
Member
Author
|
Still faster than deprecating in 3.0 and removing in 3.1. 😄 |
20aaee2 to
93c2664
Compare
lrytz
reviewed
Apr 3, 2020
lrytz
reviewed
Apr 3, 2020
93c2664 to
595a127
Compare
595a127 to
6ae3b2a
Compare
narma
reviewed
May 13, 2020
6ae3b2a to
4216bb1
Compare
Member
|
this seems ready for merge, but holding off for now until #8833 is also ready |
Member
|
@dwijnand needs rebase |
Member
|
@dwijnand this is just a lint and not an actual deprecation... right? |
Member
Author
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
Member
|
@dwijnand could you improve the PR description to document this for folks who don't already know the context/motivation? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-overrideis no longer accepted.Strongly related to deprecating auto-application (#8833).