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

Add tests to reproduce exceptions in UseVarForGenericsConstructors #259

Merged
merged 3 commits into from
Jul 17, 2023

Conversation

MBoegers
Copy link
Contributor

@MBoegers MBoegers commented Jul 12, 2023

What's changed?

UseVarForGenericsConstructors failed for some edge cases. They are documented by #257 and are fixed in this PR.

What's your motivation?

Close #257

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

Have you considered any alternatives or workarounds?

No, would lead to broken recipes.

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've added the license header to any new files through ./gradlew licenseFormat
  • I've used the IntelliJ auto-formatter on affected files
  • I've updated the documentation (if applicable)

""", """
package com.example.app;

import java.util.List;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm; we might want to clear out unused imports.

Suggested change
import java.util.List;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought about that too but added a note here java-lang-var.yml L20

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm; but wouldn't we at least be able to maybeRemoveImport the type on left side of the assignment when replaced with var (or maybe only if the left side is an interface)? If there's any other uses still then the maybe part should pick up on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wasn't aware of this. This should be rolled out to every Recipe in org.openrewrite.java.migrate.lang.var

@joanvr joanvr added bug Something isn't working enhancement New feature or request test provided labels Jul 17, 2023
@MBoegers MBoegers marked this pull request as ready for review July 17, 2023 07:50
Copy link
Contributor

@joanvr joanvr left a comment

Choose a reason for hiding this comment

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

Thank you very much for your contribution. I've been following up your PR also from the slack support channel. And indeed it's a nice and interesting improvement!
I've seen that you've added applicability code to avoid the unsupported case of generic variables with bounds, so it looks good for me :)
Would you like me to merge it already or you want to do some final changes?

@MBoegers
Copy link
Contributor Author

Hi @joanvr Thanks for the review, I'd like to apply Tims suggestion first, I think I'll be done with this PR after lunch.

…rGenericMethodInvocations and UseVarForGenericsConstructors
@MBoegers
Copy link
Contributor Author

@joanvr ready for merge from my point

@joanvr joanvr merged commit 2dde3ae into openrewrite:main Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request test provided
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Var Recipes error on Unbounded or Generic Type Parameter
3 participants