-
Notifications
You must be signed in to change notification settings - Fork 78
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
236 var for methods #249
236 var for methods #249
Conversation
bbd0a13
to
927b01d
Compare
@MBoegers Great to see you making progress here! Please ping us if you have any questions or would like us to review it. While it is still in draft, we will just let you continue working. |
…ericsConstructorsTest
Before undrafting I will implement the missing |
* Update name of UseVarForGenericMethodInvocations to reflect action * Fix yml recipe java-lang-var.yml * update tests to reflect shortcomings of open rewrite regarding generic method invocations
There was a problem hiding this 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. Couple of very small comments. Let me know if you want me to merge this PR already :)
src/test/java/org/openrewrite/java/migrate/lang/var/UseVarForGenericMethodInvocationsTest.java
Outdated
Show resolved
Hide resolved
src/test/java/org/openrewrite/java/migrate/lang/var/VarBaseTest.java
Outdated
Show resolved
Hide resolved
class A { | ||
void m() { | ||
List<Object> os = new List(); | ||
List<Object> os = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good improvement :) Our parser might be a bit too permissive sometimes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, there is warning "com/example/app/A.java:7: error: List is abstract; cannot be instantiated List os = new List<>();" but I think that should be an error.
} | ||
@Test | ||
void withDiamondOperatorOnRaw() { | ||
//todo check if this may be possible!, We could transform ArrayList into ArrayList<String> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've quickly tried to see the changes needed for this, and I think it's ok to leave it as future improvement since it requires quite not so trivial changes..
@@ -17,11 +17,14 @@ | |||
type: specs.openrewrite.org/v1beta/recipe | |||
name: org.openrewrite.java.migrate.lang.UseVar | |||
displayName: Use local variable type inference | |||
description: Apply local variable type inference (`var`) for primitives and objects. | |||
description: Apply local variable type inference (`var`) for primitives and objects. These recipes can cause unused |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Co-authored-by: Joan Viladrosa <[email protected]>
Thanks for your review. I've accepted your suggestions, after the CI succeeded I am ok with merging. |
Merged it, thank you very much again for your contribution, and thanks for the fixes on the previous recipes and tests :) |
What's changed?
Implemented Issue #236.
What's your motivation?
Make Open Rewrite
var
awareAny additional context
Method invocation without generics were already implemented by
UseVarForObject
and are only proved by additional tests.Checklist
./gradlew licenseFormat