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

Update comments referencing Refaster rule limitation #46

Merged
merged 11 commits into from
Dec 27, 2024

Conversation

rickie
Copy link
Member

@rickie rickie commented Mar 31, 2022

While applying error-prone-support on repositories within Picnic we found that for some templates we lose generic type information. Therefore, we opened a PR upstream google/error-prone#2706 to fix this. The problem is that for method invocations the type arguments were simply ignored by Refaster in the @AfterTemplates.

Our fork cherry-picked the commit from the upstream repository. In addition, we also use the fork for Picnic internally.
However, currently we are not on the latest version due to some issues.

This should prepare the code for when we upgrade EPS and PSM to v2.11.0-picnic-1 or 2.11.1 (which doesn't exist yet).

@rickie rickie added this to the 0.1.0 milestone Apr 4, 2022
@rickie rickie requested review from Stephan202 and Badbond April 6, 2022 12:22
Copy link
Member

@Badbond Badbond left a comment

Choose a reason for hiding this comment

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

Not completely comfortable with reviewing this as I was not in the loop of these problems (type arguments, wiremock, other blockers) and their fixes. Nor do I have a clear overview of which state currently the fork is in and what is currently blocking us. Brain is a bit depleted atm to really get a sense of this.

Do have some feedback that we can discuss already though.

@@ -32,9 +32,13 @@ private ImmutableListMultimapTemplates() {}
/**
* Prefer {@link ImmutableListMultimap#builder()} over the associated constructor on constructions
* that produce a less-specific type.
*
* <p>Picnic's Error Prone fork supports inlining of method arguments in the `@AfterTemplate`.
Copy link
Member

@Badbond Badbond Apr 6, 2022

Choose a reason for hiding this comment

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

I would still keep an XXX here. Now it looks like just class Javadoc; not something to take action upon.

Also, see suggestion: Right? I was so confused. Copied this from suggested commit message in upstream.

Suggested change
* <p>Picnic's Error Prone fork supports inlining of method arguments in the `@AfterTemplate`.
* <p>Picnic's Error Prone fork supports method invocation type argument inlining in the `@AfterTemplate`.

These two suggestions apply to all changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now it looks like just class Javadoc; not something to take action upon.

That was exactly what was my intention 😄.

Both you and @Stephan202 mention that it should be an XXX so I updated the Javadoc and added the feedback 😉.

Btw, let me give some extra context on this tomorrow :).

@rickie rickie force-pushed the rossendrijver/add_type_arguments_to_templates branch from 1dd72a3 to 4f28ecb Compare April 7, 2022 07:36
@Stephan202 Stephan202 modified the milestones: 0.1.0, 0.1.1 Apr 10, 2022
@Stephan202
Copy link
Member

Updated the milestone. As discussed offline, we'll merge this PR once error-prone-support depends on a version of Error Prone (or our fork) that includes google/error-prone#2706.

@Stephan202 Stephan202 removed this from the 0.1.1 milestone Aug 13, 2022
@Stephan202
Copy link
Member

Dropped this ticket from the upcoming milestone for now. Not because we don't want this change, but because we first need to formulate a solution to the "serialization compatibility question".

@rickie rickie added the blocked This blocks either a release or a downstream project label Aug 20, 2022
@rickie rickie force-pushed the rossendrijver/add_type_arguments_to_templates branch from 4f28ecb to 59b2435 Compare January 3, 2023 08:12
@github-actions
Copy link

github-actions bot commented Jan 3, 2023

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie rickie force-pushed the rossendrijver/add_type_arguments_to_templates branch from 59b2435 to d6526d3 Compare January 24, 2023 13:51
@rickie
Copy link
Member Author

rickie commented Jan 24, 2023

I looked into this again. Rebased it and tried some things. However, I think we need to have a HasTypeArgumentsMatcher or something like that. Now it unconditionally introduces the type arguments, that is not the goal I would say. So we need to have two Refaster rules per case and use the @{Not,}Matches to make sure we don't introduce it everytime.

WDYT @Stephan202?

@oxkitsune oxkitsune force-pushed the rossendrijver/add_type_arguments_to_templates branch from 845901b to 339152a Compare May 22, 2023 11:29
@rickie
Copy link
Member Author

rickie commented May 26, 2023

Well, you are right (discussed here) and indeed we cannot use a Matcher for this. In that case I'm not sure how we can best approach this. I think we need a BugChecker for this that only introduces the type arguments if we need it. If we would proceed with this PR we would introduce this while it's not necessary. Other option would be to create a check that detects we don't need the type arguments....

@Stephan202
Copy link
Member

Other option would be to create a check that detects we don't need the type arguments....

That sounds more complex, but on the plus side would enable also other cleanup. I haven't looked into it deeply, but it would amount to identifying method invocations that (a) specify explicit type parameters and (b) invoke a specific method overload that, absent such type parameters, would also be selected by the algorithm defined by JLS 18.5.2. For (b) we'd of course rely on a few heuristics; just enough to avoid false positives while still covering the cases discussed here.

@Stephan202 Stephan202 added this to the 0.20.0 milestone Dec 26, 2024
@Stephan202 Stephan202 added chore A task not related to code (build, formatting, process, ...) and removed blocked This blocks either a release or a downstream project labels Dec 26, 2024
Copy link
Member

@Stephan202 Stephan202 left a comment

Choose a reason for hiding this comment

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

I synced this branch and added two commits:

Rationale is that google/error-prone#2706 is no longer a blocker, and that instead we should make up our mind about whether to propagate the type parameters.

I suggest merging this PR with the following commit message:

Update comments referencing Refaster rule limitation (#46)

Issue google/error-prone#2706 has been resolved; we have yet to decide
how to proceed.

@Stephan202 Stephan202 changed the title Add type arguments in @AfterTemplates for builders Update comments referencing Refaster rule limitation (#46) Dec 26, 2024
@Stephan202 Stephan202 changed the title Update comments referencing Refaster rule limitation (#46) Update comments referencing Refaster rule limitation Dec 26, 2024
Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

Copy link
Contributor

@mohamedsamehsalah mohamedsamehsalah left a comment

Choose a reason for hiding this comment

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

✏️

Copy link

Looks good. No mutations were possible for these changes.
Mutation testing report by Pitest. Review any surviving mutants by inspecting the line comments under Files changed.

@rickie
Copy link
Member Author

rickie commented Dec 26, 2024

Thanks a lot @Stephan202 for picking up this old one. I think this is the right approach for now. It's an interesting case.

I encountered this case a lot when trying to implement the Guava integration tests.

I'd say lets merge this one :), updated the branch (might be offline in a bit when its ready to merge)

@Stephan202 Stephan202 merged commit 7daa39a into master Dec 27, 2024
16 checks passed
@Stephan202 Stephan202 deleted the rossendrijver/add_type_arguments_to_templates branch December 27, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore A task not related to code (build, formatting, process, ...)
Development

Successfully merging this pull request may close these issues.

5 participants