Skip to content

Patch empty implicit parens on error recovery #22835

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

Merged
merged 5 commits into from
Jul 1, 2025

Conversation

som-snytt
Copy link
Contributor

Offer a rewrite for an erroneous application f() where the parameter list is implicit and a parameter lacks a default arg.

This was never official syntax, but was accepted from 3.3.4/3.4.2 due to a bug. The rewrite is for 3.7-migration, using the existing MigrationVersion.ImplicitParamsWithoutUsing, since that is a similar bit of syntax.

Fixes #22792

@som-snytt
Copy link
Contributor Author

som-snytt commented Mar 19, 2025

Requires a tweak: an implicit param list is not supplied implicitly if an arg list is present (but defaults may be supplied in the explicit application). It must not continue implicit application when rewriting.

Ha, in other words, canApplyImplicits should be false not true. I knew it had to be one of the two.

@som-snytt som-snytt force-pushed the issue/22792-rewrite-bad-parens branch from 6fe89ef to cfa8e9f Compare March 19, 2025 16:08
@som-snytt
Copy link
Contributor Author

Added a test case for rewrite of Foo()() to Foo() instead of Foo().apply. That is a "big TODO".

@som-snytt som-snytt marked this pull request as ready for review March 21, 2025 18:28
@Gedochao Gedochao requested a review from KacperFKorban March 24, 2025 06:55
@som-snytt som-snytt force-pushed the issue/22792-rewrite-bad-parens branch from c184805 to 83fda42 Compare March 29, 2025 21:46
Copy link
Member

@KacperFKorban KacperFKorban left a comment

Choose a reason for hiding this comment

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

Looks good. I just added two small comments about the code.

@som-snytt
Copy link
Contributor Author

The spurious failure is cc timeout on posCC, negAll, runAll.

@som-snytt som-snytt force-pushed the issue/22792-rewrite-bad-parens branch from ef81b4a to da154fc Compare April 1, 2025 15:26
@som-snytt som-snytt requested a review from KacperFKorban April 2, 2025 16:04
case InfixTuple // r f (x1, ..., xN) where N != 1; needs to be treated specially for an error message in typedApply
case Regular // r.f(x)
case Using // r.f(using x)
case InfixTuple // r f (x1, ..., xN) where N != 1; needs to be treated specially for an error message in typedApply
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This keeps the line under 120 chars, not a standard but nice to have when feasible. class Apply line wraps at that length; it would be nice to alias constructorOnly to cO or something like in chemistry K.

Copy link
Member

@KacperFKorban KacperFKorban left a comment

Choose a reason for hiding this comment

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

Looks good! Sorry for taking so long, this PR got lost in my notifications 🙈

@som-snytt som-snytt force-pushed the issue/22792-rewrite-bad-parens branch from da154fc to dc178d0 Compare July 1, 2025 16:35
@som-snytt som-snytt enabled auto-merge (rebase) July 1, 2025 16:56
@som-snytt som-snytt merged commit 542ca19 into scala:main Jul 1, 2025
29 checks passed
@som-snytt som-snytt deleted the issue/22792-rewrite-bad-parens branch July 2, 2025 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants