-
Notifications
You must be signed in to change notification settings - Fork 82
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
Skip var
replacement when the type cannot fully be resolved
#608
Comments
/cc @MBoegers |
Good catch! I remember a discussion if it should be migrated to I'll pick it up soon. |
Interesting observation here. For non-static methods, they are correctly typed with Generic in the |
@uhafner the hot fix should prevent your code from breaking by never migrate variables initiated by static methods. I have to check why the OpenRewrite Java parser do not preserve the generic nature of static generic methods. Afterwards we can come back to this and readable migration of not generic method. |
When a variable is set by the return value of a method with a generic return type, then the type cannot be replaced with
var
. In such cases theUseVarForObject
recipe should skip such replacements.What version of OpenRewrite are you using?
How are you running OpenRewrite?
Maven Plugin:
What is the smallest, simplest way to reproduce the problem?
What did you see instead?
The currently generated code is not compiling on Java 21:
Are you interested in contributing a fix to OpenRewrite?
No
The text was updated successfully, but these errors were encountered: