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

Extension check checks for no parens not empty parens #22825

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Mar 17, 2025

The check for hidden extensions incorrectly tested for "empty params":

paramTps.isEmpty || memberIsImplicit && !methTp.hasImplicitParams || paramsCorrespond

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 is Nil is "nilary", but List(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 early return, 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

@som-snytt som-snytt marked this pull request as ready for review March 18, 2025 14:49
@Gedochao Gedochao requested review from rochala and KacperFKorban and removed request for rochala March 19, 2025 09:29
@som-snytt som-snytt force-pushed the issue/22821-ext-redux branch from 39a42de to 8c5194c Compare March 29, 2025 21:44
@som-snytt som-snytt merged commit d0e9062 into scala:main Apr 1, 2025
48 of 49 checks passed
@som-snytt som-snytt deleted the issue/22821-ext-redux branch April 1, 2025 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive extension method will never be selected
2 participants