-
Notifications
You must be signed in to change notification settings - Fork 72
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
UseVarForObject
creates broken code when replacing type variable
#550
Comments
lang.var.UseVarForObject
creates broken Java code when replacing with type variablelang.var.UseVarForObject
creates broken Java code when replacing type variable
lang.var.UseVarForObject
creates broken Java code when replacing type variableUseVarForObject
creates broken Java code when replacing type variable
UseVarForObject
creates broken Java code when replacing type variableUseVarForObject
creates broken code when replacing type variable
In this case the derivation of the type seems broken. Such change is indeed not correct. The expectation seems right, I'll check what's missing. Thanks for reporting 🙏 |
We can reproduce this with the test below. The issue is caused be the type boundary ( @Test
@Issue("https://github.com/openrewrite/rewrite-migrate-java/issues/550")
void genericType() {
rewriteRun(
java(
"""
import java.io.Serializable;
abstract class Outter<T extends Serializable> {
abstract T doIt();
void trigger() {
T x = doIt();
}
}
""", """
import java.io.Serializable;
abstract class Outter<T extends Serializable> {
abstract T doIt();
void trigger() {
var x = doIt();
}
}
"""
)
);
} |
One additional question @uhafner, why are you expecting |
You are right, it works with |
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project. I did run the command
mvn -X clean rewrite:run
.See https://github.com/uhafner/codingstyle for details. The OpenRewrite configuration is visible in the pom.xml.
What is the smallest, simplest way to reproduce the problem?
What did you expect to see?
Type variable should not be replaced by var.
What did you see instead?
What is the full stack trace of any errors you encountered?
No stack trace produced.
Are you interested in [contributing a fix to OpenRewrite]
Not right now.
The text was updated successfully, but these errors were encountered: