rewrite-migrate-java
rewrite-migrate-java copied to clipboard
Rewrite of empty `Set.of()` by UseEnumSetOf doesn't compile
What version of OpenRewrite are you using?
I am using
- OpenRewrite v8.27.1
- Maven plugin v5.32.1
- rewrite-module v2.16.0
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.32.1</version>
<configuration>
...
</configuration>
</plugin>
What is the smallest, simplest way to reproduce the problem?
class A {
void foo(String bar) {
final Set<TimeUnit> timeUnits = Set.of();
}
}
What did you expect to see?
Either use EnumSet.noneOf or do not do any rewrite
class A {
void foo(String bar) {
final Set<TimeUnit> timeUnits = EnumSet.noneOf(TimeUnit.class);
}
}
What did you see instead?
Uses EnumSet.of which requires an argument and since there is none, the code below does not compile
class A {
void foo(String bar) {
final Set<TimeUnit> timeUnits = EnumSet.of();
}
}
What is the full stack trace of any errors you encountered?
No exception from plugin. Rewritten code isn't compilable.
Are you interested in contributing a fix to OpenRewrite?
I can fix it when I have time but I don't know when I will so please feel free to do that.
Oh wow, thanks for reporting the issues you're finding! Seems like a straightforward special case replacement to get this fixed.