Skip to content

Commit 7a2bac9

Browse files
committed
Collect a record's members with Stream.toList()
Collectors.toUnmodifiableList() was there only because the list was declared List<Tree>, and Stream.toList() on getMembers(), a List<? extends Tree>, gives a list of the wildcard's capture. addBodyDeclarations takes a List<? extends Tree>, so the variable is a var and the stream ends in toList(), as CLAUDE.md asks.
1 parent ed5bf34 commit 7a2bac9

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎open-java-format/src/main/java/com/palantir/javaformat/java/java14/Java14InputAstVisitor.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import java.lang.reflect.Method;
4444
import java.util.List;
4545
import java.util.Optional;
46-
import java.util.stream.Collectors;
4746
import javax.lang.model.element.Name;
4847
import org.jspecify.annotations.Nullable;
4948

@@ -225,9 +224,9 @@ public void visitRecordDeclaration(ClassTree node) {
225224
if (node.getMembers() == null) {
226225
token(";");
227226
} else {
228-
List<Tree> members = node.getMembers().stream()
227+
var members = node.getMembers().stream()
229228
.filter(t -> (TreeInfo.flags((JCTree) t) & Flags.GENERATED_MEMBER) == 0)
230-
.collect(Collectors.toUnmodifiableList());
229+
.toList();
231230
addBodyDeclarations(members, BracesOrNot.YES, FirstDeclarationsOrNot.YES);
232231
}
233232
dropEmptyDeclarations();

0 commit comments

Comments
 (0)