Skip to content

Commit b2e62c8

Browse files
committed
Document an unhandled edge case
1 parent c90bfe6 commit b2e62c8

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/test/java/org/openrewrite/java/migrate/guava/NoGuavaSetsFilterTest.java

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package org.openrewrite.java.migrate.guava;
1717

1818
import org.junit.jupiter.api.Test;
19+
import org.junitpioneer.jupiter.ExpectedToFail;
20+
import org.junitpioneer.jupiter.Issue;
1921
import org.openrewrite.DocumentExample;
2022
import org.openrewrite.InMemoryExecutionContext;
2123
import org.openrewrite.java.JavaParser;
@@ -103,6 +105,8 @@ public static Set<Object> test(SortedSet<Object> set, Predicate<Object> isNotNul
103105
);
104106
}
105107

108+
@ExpectedToFail("Sets.filter has special handling for sorted sets which now gets lost")
109+
@Issue("https://github.com/openrewrite/rewrite-migrate-java/pull/898#discussion_r2461706208")
106110
@Test
107111
void replaceSetsFilterIndirectlyUsingSortedSet() {
108112
//language=java
@@ -121,22 +125,8 @@ public static Set<Object> test(SortedSet<Object> set, Predicate<Object> isNotNul
121125
return Sets.filter(indirectSet, isNotNull);
122126
}
123127
}
124-
""",
125-
"""
126-
import java.util.Set;
127-
import java.util.SortedSet;
128-
import java.util.TreeSet;
129-
import java.util.stream.Collectors;
130-
131-
import com.google.common.base.Predicate;
132-
133-
class Test {
134-
public static Set<Object> test(SortedSet<Object> set, Predicate<Object> isNotNull) {
135-
Set<Object> indirectSet = set;
136-
return indirectSet.stream().filter(isNotNull).collect(Collectors.toCollection(TreeSet::new));
137-
}
138-
}
139128
"""
129+
// This now gets converted, but skips past a `instanceof SortedSet` check that keeps it a sorted set
140130
)
141131
);
142132
}

0 commit comments

Comments
 (0)