From ca25377beb1e5e52b1a9cf1fbc2bb679e6c17926 Mon Sep 17 00:00:00 2001 From: Jonathan Schneider Date: Fri, 16 Dec 2022 18:16:31 -0500 Subject: [PATCH] Any source applicable tests should be ANDed together not ORed / fixes #2543 --- .../main/java/org/openrewrite/RecipeScheduler.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/RecipeScheduler.java b/rewrite-core/src/main/java/org/openrewrite/RecipeScheduler.java index 98c1a8513c9..4b272f878fd 100644 --- a/rewrite-core/src/main/java/org/openrewrite/RecipeScheduler.java +++ b/rewrite-core/src/main/java/org/openrewrite/RecipeScheduler.java @@ -159,13 +159,17 @@ default List scheduleVisit(RecipeRunStats runStats, ((WatchableExecutionContext) ctx).resetHasNewMessages(); } try { - for (S s : before) { - for (Recipe r : recipeStack) { - for (TreeVisitor applicableTest : r.getApplicableTests()) { - if (applicableTest.visit(s, ctx) == s) { - return before; + for (Recipe r : recipeStack) { + nextTest: + for (TreeVisitor applicableTest : r.getApplicableTests()) { + for (S s : before) { + if (applicableTest.visit(s, ctx) != s) { + continue nextTest; } } + if (!before.isEmpty()) { + return before; + } } } } catch (Throwable t) {