What version of OpenRewrite are you using?
I am using
- OpenRewrite v6.16.2
- Maven/Gradle plugin v6.16.2
- org.openrewrite.recipe:rewrite-migrate-java:2.18.1
How are you running OpenRewrite?
I am using the Gradle plugin, and my project is a multi module project.
initscript {
repositories {
maven { url "https://plugins.gradle.org/m2" }
}
dependencies {
classpath("org.openrewrite:plugin:6.16.2")
}
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:latest.release")
rewrite("org.openrewrite.recipe:rewrite-migrate-java:2.18.1")
}
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
}
and run
./gradlew --init-script rewrite.gradle rewriteRun -Drewrite.activeRecipe=org.openrewrite.staticanalysis.InstanceOfPatternMatch
What is the smallest, simplest way to reproduce the problem?
A code snippet can be something simple like this.
if(obj instanceof List) {
test((List)list);
}
static public String test(List<String> list){
What did you expect to see?
if(obj instanceof List list) {
test(list);
}
static public String test(List<String> list){
What did you see instead?
if(obj instanceof List<?> list) {
test(list);
}
static public String test(List<String> list){
List<?> is not the same as List , this will result in a compilation error like this:
error: incompatible types: List<CAP#1> cannot be converted to List<String>
test(list));
^
where CAP#1 is a fresh type-variable:
CAP#1 extends Object from capture of ?
Indicate if this is something you would like to work on, and how we can best support you in doing so.
What version of OpenRewrite are you using?
I am using
How are you running OpenRewrite?
I am using the Gradle plugin, and my project is a multi module project.
and run
What is the smallest, simplest way to reproduce the problem?
A code snippet can be something simple like this.
What did you expect to see?
What did you see instead?
List<?>is not the same asList, this will result in a compilation error like this:Are you interested in contributing a fix to OpenRewrite?
Indicate if this is something you would like to work on, and how we can best support you in doing so.