Extension check checks for no parens not empty parens #22825
Merged
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.
The check for hidden extensions incorrectly tested for "empty params":
but that intended to check for "no params" or "nilary" method. However, "nilary method" is a misnomer here, because the result type is "not even" a method type. (The nomenclature from Scala 2 is that a method with
paramss
that isNil
is "nilary", butList(Nil)
is "nullary".)The check is corrected and moved to the beginning of the method, now called
memberHidesMethod
. It is a rare early return.Other calculated values are pushed into their use sites, in another mild refactor to aid reading and avoid calculating vals that won't be used.
If we had indentation syntax for
&&
, I would have avoided the earlyreturn
, but I was not willing to add braces.I removed the check file instead of updating line numbers because the information is repetitive. The interesting part is that it names the target type.
The test file omitted the case where the extension is nullary not nilary, so that is added.
Fixes #22821