Open jbessels opened 1 year ago
When refactoring the following Java class using the InlineVariable
recipe, the result looks correct (it inlines the newMapSortedByOrder
variable), but as stated in the issue, it doesn't compile anymore:
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
class Test {
void test() {
new MapDropdownChoice<String, Integer>(() -> {
Map<String, Integer> statuses = new java.util.HashMap<>();
Map<String, Integer> newMapSortedByOrder = statuses.entrySet().stream()
.sorted(Comparator.comparingInt(e -> e.getValue()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
return newMapSortedByOrder;
});
}
static class MapDropdownChoice<K, V> extends DropdownChoice<K> {
public MapDropdownChoice(final IModel<? extends Map<K, ? extends V>> choiceMap) {
}
}
interface IModel<T> {
T getObject();
}
static class DropdownChoice<T> {
}
}
Note The problem can probably be boiled down even more.
I have the following
public enum ImportType
. With the following methodorg.openrewrite.java.cleanup.InlineVariable translates this to
This does no longer compile. Correct code suggested by IntelliJ
I hope this is enough to reproduce the issue.