diff --git a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest8Test.java b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest8Test.java index d0aab4e9874..77608c27e70 100644 --- a/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest8Test.java +++ b/rewrite-java-test/src/test/java/org/openrewrite/java/JavaTemplateTest8Test.java @@ -86,7 +86,7 @@ void parameterizedMatchWithBounds() { @Override public N visitTypeName(N nameTree, ExecutionContext ctx) { // the cursor points at the parent when `visitTypeName()` is called - if (template.matches(new Cursor(getCursor(), nameTree))) { + if (getCursor().getValue() != nameTree && template.matches(new Cursor(getCursor(), nameTree))) { return SearchResult.found(nameTree); } return super.visitTypeName(nameTree, ctx);