Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
if (NEXT_MATCHER.matches(nextInvocation) && ITERATOR_MATCHER.matches(nextInvocation.getSelect())) {
J.MethodInvocation iteratorInvocation = (J.MethodInvocation) nextInvocation.getSelect();
Expression iteratorSelect = iteratorInvocation.getSelect();
if (TypeUtils.isAssignableTo("java.util.SequencedCollection", iteratorSelect.getType())) {
if (iteratorSelect != null && TypeUtils.isAssignableTo("java.util.SequencedCollection", iteratorSelect.getType())) {
JavaType.Method getFirst = iteratorInvocation.getMethodType().withName("getFirst");
return iteratorInvocation
.withName(iteratorInvocation.getName().withSimpleName("getFirst").withType(getFirst))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,22 @@ void bar(List<String> collection) {
)
);
}

@Test
void implicitThisIteratorNextUnchanged() {
rewriteRun(
//language=java
java(
"""
import java.util.*;
class Foo extends ArrayList<String> {
void bar() {
String first = iterator().next();
}
}
"""
)
);
}
}